打印
[STM32L4+]

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

[复制链接]
504|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
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官方仓库
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后编译
cmake -B build
cmake --build build -j8


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


lsusb结果

lsusb -v结果
Bus 001 Device 006: ID 0483:5730 STMicroelectronics Audio Speaker
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            2 Communications
  bDeviceSubClass         2 Abstract (modem)
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x0483 STMicroelectronics
  idProduct          0x5730 Audio Speaker
  bcdDevice            2.00
  iManufacturer           1 STMicroelectronics
  iProduct                2 STM32 AUDIO Streaming in FS Mode
  iSerial                 3 00000000034F
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x006e
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol      0
      iInterface              0
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               1.00
        wTotalLength       0x0027
        bInCollection           1
        baInterfaceNr(0)        1
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0201 Microphone
        bAssocTerminal          0
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0
        iTerminal               0
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 2
        bSourceID               1
        bControlSize            1
        bmaControls(0)       0x00
        bmaControls(1)       0x02
          Volume Control
        bmaControls(2)       0x02
          Volume Control
        iFeature                0
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             3
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               2
        iTerminal               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0
      iInterface              0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0
      iInterface              0
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           3
        bDelay                  1 frames
        wFormatTag         0x0001 PCM
      AudioStreaming Interface Descriptor:
        bLength                11
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            1 Discrete
        tSamFreq[ 0]        48000
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x00c8  1x 200 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioStreaming Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x00
          bLockDelayUnits         0 Undefined
          wLockDelay         0x0000





那咱们开始录音,先看看alsa识别出没有

可以看到arecord识别出usb麦克风了,card1,device0就是

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


aplay播放看看
aplay /tmp/test.wav


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

使用特权

评论回复
沙发
AdaMaYun| | 2024-9-9 17:39 | 只看该作者
楼主硬件都是哪些?有相关链接嘛?

使用特权

评论回复
板凳
一嗓子超人| | 2024-9-10 17:37 | 只看该作者
牛的

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

20

主题

62

帖子

0

粉丝