cancel
Showing results for 
Search instead for 
Did you mean: 

PDM 2 PCM help

kcire L.
Associate III

Hi,

I am trying to interface a PDM mems microphone to my STM32 NUCLEO using some example code I found https://github.com/YetAnotherElectronicsChannel/STM32_PDM_Microphone.

The issue I am having is this code and other things I have read online show the PDM2PCM converting 16 output samples from one call to PDM_Filter().

What I am really trying to do is get a single sample from the microphone when I call PDM_Filter() and send that single sample in a packet (with other information) over UART.

When I change the output sample to 1, do I need to change the number of PDM samples that are received in the PDM_Filter() or in the I2S receive function? I don't seem to be getting good data when I change from 16 output samples to 1.

Any information on this, or a better explanation of the conversion from I2S to PDM to PCM would really be appreciated.

Thanks in advanced.

Some code below.

// Here are the PDM parameters  
 
PDM1_filter_handler.bit_order = PDM_FILTER_BIT_ORDER_MSB;
  PDM1_filter_handler.endianness = PDM_FILTER_ENDIANNESS_BE;
  PDM1_filter_handler.high_pass_tap = 2104533974;
  PDM1_filter_handler.in_ptr_channels = 1;
  PDM1_filter_handler.out_ptr_channels = 1; 
  PDM_Filter_Init(&PDM1_filter_handler);
 
  PDM1_filter_config.decimation_factor = PDM_FILTER_DEC_FACTOR_64;
  PDM1_filter_config.output_samples_number = 16;
  PDM1_filter_config.mic_gain = 0; 
  PDM_Filter_setConfig(&PDM1_filter_handler, &PDM1_filter_config);
 
 
// Below are my I2S and PDM calls
 
   HAL_I2S_Receive_DMA(&hi2s2, &pdmRxBuf[0],64);
 
   PDM_Filter(&pdmRxBuf[0],&MidBuffer[0], &PDM1_filter_handler);

0 REPLIES 0