'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:
- I tried simple reading with
HAL_I2S_Receive_DMA(&hi2s3, i2sbuffer, 100);whichuint16_t i2sbuffer[256];and the result is random character (E⸮h2FI⸮g⸮⸮F⸮⸮⸮). - I'm using
PDM_Filterfrompdm2pcm_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?
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tom V |
