[STM32L4+] 【STEVAL-STWINKT1B测评】x-cube-memsmic1初尝试既数字/模拟MEMS麦克风的使用

[复制链接]
 楼主| xhackerustc 发表于 2024-9-8 09:43 | 显示全部楼层 |阅读模式
<
ev, ic, ST, TE, MEMS, win
#申请原创#

STEVAL-STWINKT1B开发板带了两个麦克风:工业级数字MEMS麦克风IMP34DT05以及模拟MEMS麦克风IMP23ABSU。IMP34DT05我们可能不熟,但是它的大哥MP34DT01那可是大名鼎鼎,某宝上很多MP34DT01芯片做 的模块,笔者恰好也有一个,使用简单效果好,接MCU的PDM输入信号录音用,应用在一些需要音频输入控制的场景下。一般而言MCU开发板用都已经买模块了当然直接用数字MEMS麦克风模块了,不需再接放 大器和ADC,接线麻烦,但是不妨碍一些开发板会板载模拟MEMS麦克风,笔者这也是第一次使用模拟MEMS麦克风。扯远了回到测评主题。

我们先看看IMP34DT05硬件功能特性:

• 单供电电压
• 低功耗
• 声过载点122.5 dBSPL
• 64 dB信噪比
• 全指向灵敏度
• 灵敏度–26 dBFS ± 3 dB
• 输出为PDM
应用场景包括但不限于:移动终端、笔记本电脑、移动多媒体播放器、VoIP、语音室别、游戏/虚拟现 实输入设备、数字相机、多媒体摄像头等等。

和它大哥MP34DT01很像,一些参数比它大哥MP34DT01有提升,所以基本肯定用起来会和它大哥一样顺手。

再看看IMP23ABSU的硬件功能特性:
• 单供电电压,1.52 V - 3.6 V
• 全指向灵敏度
• 高信噪比
• 高声过载点: 130 dBSPL典型值.
• 超扁平的频率响应
• 高达80kHZ的Ultrasound带宽
• 低延迟
• 超低功耗: 最大150 µA.

这两麦克风在板子原理图上解法蛮简单的,IMP34DT05除地、电源外,clk和DOUT引脚接入了主控STM32L4R9ZIJ6的DFSDM1的相应针脚,这就完事了接法简单利落。IMP23ABSU麻烦点,引脚出来先接放大器,把信号放大后接主控STM32L4R9ZIJ6的ADC1。

接下来我们看看软件部分,这两MEMS麦克风在fp-sns-datalog2项目仓库中都有代码支持,但例子application里没用上它们两,在STM的官方github中笔者本人翻到了一个名叫x-cube-memsmic1项目,非常有意思,音频相关的代码全、例子多,恰好也支持STEVAL-STWINKT1B开发板,所以这篇文章是不用写任何代码的,直接clone官方仓库
  1. git clone https://github.com/STMicroelectronics/x-cube-memsmic1.git


笔者选用的demo例子是Projects/STM32L4R9ZI-STWIN/Demonstration/Microphones_Streaming/,这是把STEVAL-STWINKT1B板子做成了一个usb麦克风,可以在电脑、平板上录音。此项目并无linux下编译用的cmake或makefile,但基于MDK-ARM proj写CMakeLists.txt这是基本功了这里不赘述。写完CMakeLists.txt后编译
  1. cmake -B build
  2. cmake --build build -j8


烧录后把板子usb线接入电脑,dmesg会发现linux内核已经识别出这是一个名为STM32 Audio Streaming in FS mode的usb audio设备,并加载了通用的snd-usb-audio驱动
1.jpg

lsusb结果
2.jpg
lsusb -v结果
  1. Bus 001 Device 006: ID 0483:5730 STMicroelectronics Audio Speaker
  2. Couldn't open device, some information will be missing
  3. Device Descriptor:
  4.   bLength                18
  5.   bDescriptorType         1
  6.   bcdUSB               2.00
  7.   bDeviceClass            2 Communications
  8.   bDeviceSubClass         2 Abstract (modem)
  9.   bDeviceProtocol         0
  10.   bMaxPacketSize0        64
  11.   idVendor           0x0483 STMicroelectronics
  12.   idProduct          0x5730 Audio Speaker
  13.   bcdDevice            2.00
  14.   iManufacturer           1 STMicroelectronics
  15.   iProduct                2 STM32 AUDIO Streaming in FS Mode
  16.   iSerial                 3 00000000034F
  17.   bNumConfigurations      1
  18.   Configuration Descriptor:
  19.     bLength                 9
  20.     bDescriptorType         2
  21.     wTotalLength       0x006e
  22.     bNumInterfaces          2
  23.     bConfigurationValue     1
  24.     iConfiguration          0
  25.     bmAttributes         0x80
  26.       (Bus Powered)
  27.     MaxPower              100mA
  28.     Interface Descriptor:
  29.       bLength                 9
  30.       bDescriptorType         4
  31.       bInterfaceNumber        0
  32.       bAlternateSetting       0
  33.       bNumEndpoints           0
  34.       bInterfaceClass         1 Audio
  35.       bInterfaceSubClass      1 Control Device
  36.       bInterfaceProtocol      0
  37.       iInterface              0
  38.       AudioControl Interface Descriptor:
  39.         bLength                 9
  40.         bDescriptorType        36
  41.         bDescriptorSubtype      1 (HEADER)
  42.         bcdADC               1.00
  43.         wTotalLength       0x0027
  44.         bInCollection           1
  45.         baInterfaceNr(0)        1
  46.       AudioControl Interface Descriptor:
  47.         bLength                12
  48.         bDescriptorType        36
  49.         bDescriptorSubtype      2 (INPUT_TERMINAL)
  50.         bTerminalID             1
  51.         wTerminalType      0x0201 Microphone
  52.         bAssocTerminal          0
  53.         bNrChannels             2
  54.         wChannelConfig     0x0003
  55.           Left Front (L)
  56.           Right Front (R)
  57.         iChannelNames           0
  58.         iTerminal               0
  59.       AudioControl Interface Descriptor:
  60.         bLength                10
  61.         bDescriptorType        36
  62.         bDescriptorSubtype      6 (FEATURE_UNIT)
  63.         bUnitID                 2
  64.         bSourceID               1
  65.         bControlSize            1
  66.         bmaControls(0)       0x00
  67.         bmaControls(1)       0x02
  68.           Volume Control
  69.         bmaControls(2)       0x02
  70.           Volume Control
  71.         iFeature                0
  72.       AudioControl Interface Descriptor:
  73.         bLength                 9
  74.         bDescriptorType        36
  75.         bDescriptorSubtype      3 (OUTPUT_TERMINAL)
  76.         bTerminalID             3
  77.         wTerminalType      0x0101 USB Streaming
  78.         bAssocTerminal          0
  79.         bSourceID               2
  80.         iTerminal               0
  81.     Interface Descriptor:
  82.       bLength                 9
  83.       bDescriptorType         4
  84.       bInterfaceNumber        1
  85.       bAlternateSetting       0
  86.       bNumEndpoints           0
  87.       bInterfaceClass         1 Audio
  88.       bInterfaceSubClass      2 Streaming
  89.       bInterfaceProtocol      0
  90.       iInterface              0
  91.     Interface Descriptor:
  92.       bLength                 9
  93.       bDescriptorType         4
  94.       bInterfaceNumber        1
  95.       bAlternateSetting       1
  96.       bNumEndpoints           1
  97.       bInterfaceClass         1 Audio
  98.       bInterfaceSubClass      2 Streaming
  99.       bInterfaceProtocol      0
  100.       iInterface              0
  101.       AudioStreaming Interface Descriptor:
  102.         bLength                 7
  103.         bDescriptorType        36
  104.         bDescriptorSubtype      1 (AS_GENERAL)
  105.         bTerminalLink           3
  106.         bDelay                  1 frames
  107.         wFormatTag         0x0001 PCM
  108.       AudioStreaming Interface Descriptor:
  109.         bLength                11
  110.         bDescriptorType        36
  111.         bDescriptorSubtype      2 (FORMAT_TYPE)
  112.         bFormatType             1 (FORMAT_TYPE_I)
  113.         bNrChannels             2
  114.         bSubframeSize           2
  115.         bBitResolution         16
  116.         bSamFreqType            1 Discrete
  117.         tSamFreq[ 0]        48000
  118.       Endpoint Descriptor:
  119.         bLength                 9
  120.         bDescriptorType         5
  121.         bEndpointAddress     0x81  EP 1 IN
  122.         bmAttributes            5
  123.           Transfer Type            Isochronous
  124.           Synch Type               Asynchronous
  125.           Usage Type               Data
  126.         wMaxPacketSize     0x00c8  1x 200 bytes
  127.         bInterval               1
  128.         bRefresh                0
  129.         bSynchAddress           0
  130.         AudioStreaming Endpoint Descriptor:
  131.           bLength                 7
  132.           bDescriptorType        37
  133.           bDescriptorSubtype      1 (EP_GENERAL)
  134.           bmAttributes         0x00
  135.           bLockDelayUnits         0 Undefined
  136.           wLockDelay         0x0000





那咱们开始录音,先看看alsa识别出没有
3.jpg
可以看到arecord识别出usb麦克风了,card1,device0就是

录音5s看看
  1. arecord -Dhw:1,0 -d 5 -f dat -r48000 -c 2 -t wav /tmp/test.wav
5.jpg

aplay播放看看
  1. aplay /tmp/test.wav
6.jpg

笔者本人测试感觉这麦克风效果挺好的,并不比市面上几大百耳麦中的麦克风差,完全可以用来开会打电话

AdaMaYun 发表于 2024-9-9 17:39 | 显示全部楼层
楼主硬件都是哪些?有相关链接嘛?
一嗓子超人 发表于 2024-9-10 17:37 | 显示全部楼层
牛的
埃娃 发表于 2024-9-21 12:12 | 显示全部楼层
这个功耗平均值是多少啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

42

主题

165

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部