STM32 Read mic value (MP34DT05-A) from I2S DMA

938 views Asked by At

I want to read MEMS microphone (MP34DT05-A) value (in ASCII) from STM32F107 board. I'm using I2S to communicate with the microphone.

What I did:

  • I tried simple reading with HAL_I2S_Receive_DMA(&hi2s3, i2sbuffer, 100); which uint16_t i2sbuffer[256]; and the result is random character (E⸮h2FI⸮g⸮⸮F⸮⸮⸮).
  • I'm using PDM_Filter from pdm2pcm_glo.h (STM32_Audio\Addons\PDM library):
HAL_I2S_Receive_DMA(&hi2s3, pdm_buff, 16);
PDM_Filter(&cbuff[0], &pcm_buff[0], &PDM1_filter_handler);

and the result still random character (d⸮⸮l⸮巳⸮N#⸮&6⸮4q٣⸮#⸮d⸮ɻ&⸮}⸮).

Should I need conversion for the data? Or I did something wrong?

1

There are 1 answers

1
Tom V On BEST ANSWER

A PDM microphone does not output ASCII!

The PDM microphone outputs a sequence of 1-bit values.

The function PDM_Filter converts it to PCM, which is a sequence of 16-bit values, still in binary.

To print the 16 bit sequence as text, you would need to do something like:

printf("%hi,", pcm_buff[0]);
printf("%hi,", pcm_buff[1]);
...

but obviously you can use a loop.