stm32pcmdmai2s

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


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:

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?


Solution

  • 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.