STM32从I2S DMA读取麦克风值(MP34DT05-A)
我想从 STM32F107 板读取 MEMS 麦克风 (MP34DT05-A) 值(ASCII 格式)。我正在使用 I2S 与麦克风通信。
我做了什么:
- 我尝试使用
HAL_I2S_Receive_DMA(&hi2s3, i2sbuffer, 100);
进行简单读取,其中uint16_t i2sbuffer[256];
,结果是随机字符 (E⸮h2FI⸮g⸮⸮F⸮⸮⸮)。
- 我正在使用
pdm2pcm_glo.h
(STM32_Audio\Addons\PDM 库
)中的PDM_Filter
:
HAL_I2S_Receive_DMA(&hi2s3, pdm_buff, 16);
PDM_Filter(&cbuff[0], &pcm_buff[0], &PDM1_filter_handler);
结果仍然是随机字符(d⸮⸮l⸮巳⸮N#⸮&6⸮4q٣⸮#⸮d⸮ɻ&⸮}⸮
)。
我需要对数据进行转换吗?还是我做错了什么?
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_Filter
frompdm2pcm_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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PDM 麦克风不输出 ASCII!
PDM 麦克风输出一系列 1 位值。
函数 PDM_Filter 将其转换为 PCM,它是 16 位值的序列,仍然是二进制的。
要将 16 位序列打印为文本,您需要执行以下操作:
但显然您可以使用循环。
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:
but obviously you can use a loop.