Skip to main content
Explorer
July 2, 2025
Solved

PDM2PCM stereo audio acquisition via SAI/ I2S

  • July 2, 2025
  • 3 replies
  • 580 views

Hello Gurus :)), I am currently trying to acquire 2 mic stereo data with SAI interface and have some questions regarding to de-interleave the input PDM stream. My nucleo board is nucleo-f446re. I am currently acquiring 8 bit pdm data with the relevant pdm buffer, but I am not certain if these PDM input stereo data are bit-interleaved or byte-interleaved.I have already read AN446, STM32 microphone acquisition youtube 8 video series, UM2372, rm for my board, and most of they say they are bit interleaved but in XCUBE-MEMS1 package example, I saw no deinterleaving or anything.  If they are bit-interleaved, do I need to conduct bit-masking and bit-shifting before processing them in PDM2PCM middleware? Would love to know some sample codes too. 

    This topic has been closed for replies.
    Best answer by Dor_RH

    Hello @Matthew_,

    Microphones naturally output bit-interleaved data.

    • When capturing with SAI using the I2S interface, the data remains bit-interleaved.
    • However, some SAI instances with PDM support provide byte-interleaved data directly, ready for software use.

    If you have bit-interleaved data, you need to apply bit-masking and shifting to convert it into byte-interleaved format before processing.

    I hope my answer has helped you. When your question is answered, please select this topic as the solution that answered you, as it will help others find that answer faster.

    Thanks for your contribution.

    Dor_RH

    3 replies

    ST Employee
    July 2, 2025

    Hello @Matthew_,

    I recommend consulting the following application notes and tutorial:

    • AN3998: This application note offers comprehensive details on using digital MEMS microphones with STM32 microcontrollers, including the PDM to PCM conversion process.
    • AN5027: This document explains the software decoding of PDM audio streams into PCM format on STM32 microcontrollers.
    • PDM to PCM Conversion Tutorial: This step-by-step tutorial guides you through setting up and performing PDM to PCM conversion.

    Additionally, I suggest checking out these posts on the STMicroelectronics Community:

    I hope my answer has helped you. When your question is answered, please select this topic as the solution that answered you, as it will help others find that answer faster.

    Thanks for your contribution.

    Dor_RH

    Matthew_Author
    Explorer
    July 4, 2025

    Hello @Dor_RH  Thank you so much for your answers. I have checked out the links you mentioned, but it would be great to clearly confirm that the incoming pdm streams from the microphones are either bit-interleaved or byte-interleaved because i see no deinterleaving steps in the successful community post you mentioned. Really appreciate your help. 

    Dor_RHAnswer
    ST Employee
    July 7, 2025

    Hello @Matthew_,

    Microphones naturally output bit-interleaved data.

    • When capturing with SAI using the I2S interface, the data remains bit-interleaved.
    • However, some SAI instances with PDM support provide byte-interleaved data directly, ready for software use.

    If you have bit-interleaved data, you need to apply bit-masking and shifting to convert it into byte-interleaved format before processing.

    I hope my answer has helped you. When your question is answered, please select this topic as the solution that answered you, as it will help others find that answer faster.

    Thanks for your contribution.

    Dor_RH

    Matthew_Author
    Explorer
    July 8, 2025

    Hello @Dor_RH , thank you so much. This helps me pin down my problem.