0

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?

Pnzy
  • 25
  • 5

1 Answers1

0

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.

Tom V
  • 4,827
  • 2
  • 5
  • 22
  • In which bit I can use to measurement? Or is there any other method? I want to use it as sound trigger. – Pnzy Mar 29 '22 at 07:10