cancel
Showing results for 
Search instead for 
Did you mean: 

How to get PDM data to SAI from STM32WB55 and convert it to a PCM signal?

RKrüg.1145
Associate

Hi,

I have a problem with an audio application on the STM32WB55 board. I would like to receive data from a digital microphone over the SAI inferface. I setup the Clock for this interface to 3.09MHz. After that I receive Data over the interface by polling the sensor. For the conversion to a PCM signal I use the PDM library and the PDM_Filter() function.

My output signal from this funktion isn´t correct. I don´t know, if my receiving function is correct, too. I append some photos of the PDM signal and the PCM signal. I am new in microcontroller programming. I would be glad if anyone has some advice for me.

Thanks Robin

1 REPLY 1
Eleon BORLINI
ST Employee

Hi Robin, I checked with our experts and they told me as follows. Regarding the code you shared, there is a couple of things that should be revised:

  • You are reading mic data from the SAI interface in a blocking way
  • You begin data processing when you have read some data, but during this phase your acquisition is blocked, because at the beginning of each processing cycle you re-initialize the PDM to PCM function, taking an internal state of the filter; then you perform the FFT (with the acquisition still blocked) and then you transmit the data through printf method, which is very slow for an audio data stream.

The suggested method to acquire and process microphone data is to use the DMA and related functions. For this reason, I suggest you to check in the MEMSMIC1 CubeMX function pack the PDM-PCM conversion example for your specific MCU (STM32WB55 ). By now, this example uses the SAI as I2S, the standard digital audio interface but, having this part number a dedicated PDM acquisition peripheral, the ideal thing would be use this feature. However, there is no example dedicated; it should be ready by the end of this year.

Regards