cancel
Showing results for 
Search instead for 
Did you mean: 

Using PDM to PCM conversion library

J Lee
Associate III

I am using a STM32L1 MCU and I want to use the PDM to PCM conversion library, so I downloaded X-CUBE-MEMSMIC1, in the audio PDM lib folder I found libPDMFilter_CM3_Keil.lib.

In the release note I read this lib is for 16KHz PCM data sampling rate, So my questions are:

  1. Does "16KHz" mean 16KHz sampling rate from the already sampled PDM data? My final and overall audio sampling rate exceeds 16 KHz, I don't think here the 16 KHz equals to the final and overall sampling rate of audio data. For example, if I increase the PDM sampling rate, though the constant 16 KHz sampling rate when it comes to PDM to PCM conversion, the final and overall sampling rate will increase.
  2. Is there a guide on how to configure filtering paramters?

Thank you in advance

4 REPLIES 4
ArturasV
Senior

Hi J Lee, i am actually struggling with PDM->PCM library from ST fro the past few days. Can't get it to work. You can see my post here: https://community.st.com/s/question/0D50X00009cf4vsSAA/reading-pdm-data-from-mp34dt05a-with-stm32f407-i2s

I wrote document numbers in my post that has the information how to use that library. If you get it working corectly, please let my know.

Imen.D
ST Employee

Hello @Community member​ ,

Have a look to this user manual UM2372, it maybe helpful.

With Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
J Lee
Associate III

@Imen DAHMEN​ 

Thank you very much for your help, actually I am using cube MX to configure the I2S interface and I am using STM32L152RE-NUCLEO board, it seems in the clk config section, there's no specifed i2S clk config module ( see the screeshot in attatchment), so in this case how can I configure the i2s clock? Can I consider APB1_Prepherial_CLK as the I2S clk since I2S use PB1x pins?

I tried to measure the PDM sampling rate by measuring elapsed time in keil in this case, I don't know if it's fesiable?

Thank you very much

Imen.D
ST Employee

Hello @Community member​ ,

Regarding the question about I2S clock, It's true that STM32L1 has not a dedicated audio PLL:

I2S peripheral receive the clock from AHB clock. The clock tree shown in the image is a good choice for this use case.

The clock is then generated by I2S and it depends on the I2S peripheral configuration: in general, to target 1 channel recording with a PDM sampling frequency equal to PDM_CLK (for example 1.28 MHz), a good choice for the I2S parameters is:

hAudioInI2s.Instance = SPI2

hAudioInI2s.Init.DataFormat = I2S_DATAFORMAT_16B;

hAudioInI2s.Init.AudioFreq = (PDM_CLK / 32);

hAudioInI2s.Init.CPOL = I2S_CPOL_HIGH;

hAudioInI2s.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE;

hAudioInI2s.Init.Mode = I2S_MODE_MASTER_RX;

hAudioInI2s.Init.Standard = I2S_STANDARD_MSB;

Kind Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen