Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
AUDIO
wavplayer
Numaker-IoT-M487
【开发板评测】NuvotonM487 Audio模块测试
发布于 2022-04-16 23:44:58 浏览:771
订阅该版
[tocm] # 1 开发板介绍 ## 1.1 外设 ![022762863823fa117320c2486215896.jpg](https://oss-club.rt-thread.org/uploads/20220409/b61b955d782c3a6577bedd2f8385484a.jpg.webp) ## 1.2 特性 ![c69b6c6bca01e8a3e5946a1610d6bf5.jpg](https://oss-club.rt-thread.org/uploads/20220409/198761b10afb7d070b8dff644e239cd1.jpg.webp) ## 1.3 块表 ![0edafe9d37ee414ffacaa6e6c232500.jpg](https://oss-club.rt-thread.org/uploads/20220409/e158e5b3d8d31a4c963a0edfb3034a1c.jpg.webp) ## 1.4 AUDIO硬件原理 ![image.png](https://oss-club.rt-thread.org/uploads/20220410/e33389d2d1c39d525420b4dfb3b0083d.png.webp) # 2 开发环境搭建(GCC方式) PC环境:win10 [NuMaker-IoT-M487 上手指南](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/quick-start/numaker-iot-m487/quick-start) ## 2.1 Env RT-Thread 开发辅助工具 [env_released_1.2.0.7z](https://download-sh-cmcc.rt-thread.org:9151/www/aozima/env_released_1.2.0.7z) 解压后即可打开env.bat或env.exe即可使用(注意解压路径里最好不能有中文和空格) ![image.png](https://oss-club.rt-thread.org/uploads/20220409/246b978d7d5ceca35f4229e93ddb8622.png.webp) ## 2.2 安装Nu-Linker驱动 [Nu-Link_IAR 驱动](https://www.nuvoton.com/resource-download.jsp?tp_GUID=SW1120200221180914)里有Nu-Link_USB_Driver 1.8.exe这个驱动安装文件。 装完驱动后,使用 USB 线连接开发板的 USB ICE Connector 到 PC 机,会检测到COM口,如下图: ![image.png](https://oss-club.rt-thread.org/uploads/20220409/553933a7153118c1b48736227e7e498d.png.webp) ## 2.3 源码获取 https://gitee.com/rtthread/rt-thread.git ``` Administrator@BKL85SWJMT1GA7J E:\NuMaker > git clone https://gitee.com/rtthread/rt-thread.git Cloning into 'rt-thread'... remote: Enumerating objects: 187653, done. remote: Counting objects: 100% (13282/13282), done. remote: Compressing objects: 100% (6418/6418), done. remote: Total 187653 (delta 8657), reused 9783 (delta 6665), pack-reused 174371 Receiving objects: 100% (187653/187653), 524.46 MiB | 3.55 MiB/s, done. Resolving deltas: 100% (134067/134067), done. Updating files: 100% (28432/28432), done. ``` ## 2.4 下载项目(NuMaker-IoT-M487)相关套件 `cd bsp\nuvoton\numaker-iot-m487`: 切换到numaker-iot-m487的工作目录; `menuconfig --generate`: 根据.config生成rtconfig.h文件; `pkgs --update`: 从git repo上更新本地包和Env脚本(应该时根据.config文件); > menuconfig可以修改整个工程配置; > pkgs --printenv也很有用,可以查看Env的环境变量; ``` Administrator@BKL85SWJMT1GA7J E:\NuMaker > cd bsp\nuvoton\numaker-iot-m487\ Administrator@BKL85SWJMT1GA7J E:\NuMaker\rt-thread\bsp\nuvoton\numaker-iot-m487 > menuconfig --generate Administrator@BKL85SWJMT1GA7J E:\NuMaker\rt-thread\bsp\nuvoton\numaker-iot-m487 > pkgs --update Cloning into 'E:\NuMaker\rt-thread\bsp\nuvoton\numaker-iot-m487\packages\at_device-latest'... remote: Enumerating objects: 1647, done. remote: Counting objects: 100% (150/150), done. remote: Compressing objects: 100% (138/138), done. remote: Total 1647 (delta 80), reused 39 (delta 8), pack-reused 1497R Receiving objects: 100% (1647/1647), 689.47 KiB | 222.00 KiB/s, done. Resolving deltas: 100% (1050/1050), done. ==============================> AT_DEVICE latest is downloaded successfully. ==============================> at_device update done Operation completed successfully. ``` ## 2.5 GCC 编译项目 > Env RT-Thread环境中已有arm-none-eabi交叉编译链; > scons进行自动构建,生成rtthread.bin ### 2.5.1 检测交叉编译链工具 ``` env_released_1.2.0\env > arm-none-eabi- arm-none-eabi-addr2line.exe arm-none-eabi-gcc-nm.exe arm-none-eabi-nm.exe arm-none-eabi-ar.exe arm-none-eabi-gcc-ranlib.exe arm-none-eabi-objcopy.exe arm-none-eabi-as.exe arm-none-eabi-gcc.exe arm-none-eabi-objdump.exe arm-none-eabi-c++.exe arm-none-eabi-gcov-tool.exe arm-none-eabi-ranlib.exe arm-none-eabi-c++filt.exe arm-none-eabi-gcov.exe arm-none-eabi-readelf.exe arm-none-eabi-cpp.exe arm-none-eabi-gdb-py.exe arm-none-eabi-size.exe arm-none-eabi-elfedit.exe arm-none-eabi-gdb.exe arm-none-eabi-strings.exe arm-none-eabi-g++.exe arm-none-eabi-gprof.exe arm-none-eabi-strip.exe arm-none-eabi-gcc-5.4.1.exe arm-none-eabi-ld.bfd.exe arm-none-eabi-gcc-ar.exe arm-none-eabi-ld.exe ``` ### 2.5.2 scons构建 注意:一定要切到项目下构建(rt-thread\\bsp\\nuvoton\\numaker-iot-m487) ``` > scons scons: Reading SConscript files ... Newlib version:2.4.0 scons: done reading SConscript files. scons: Building targets ... scons: building associated VariantDir targets: build CC build\applications\main.o CC build\applications\mnt.o CC build\board\board_dev.o CC build\board\NuClockConfig\nutool_modclkcfg.o CC build\board\NuPinConfig\nutool_pincfg.o 此处打印太多省略 CC E:\NuMaker\rt-thread\bsp\nuvoton\libraries\nu_packages\AudioCodec\audio_test.o CC E:\NuMaker\rt-thread\bsp\nuvoton\libraries\nu_packages\AudioCodec\acodec_nau88l25.o CC E:\NuMaker\rt-thread\bsp\nuvoton\libraries\nu_packages\BMX055\libraries\BMG160_driver\bmg160.o CC E:\NuMaker\rt-thread\bsp\nuvoton\libraries\nu_packages\BMX055\libraries\BMA2x2_driver\bma2x2.o CC E:\NuMaker\rt-thread\bsp\nuvoton\libraries\nu_packages\BMX055\sensor_bmx055.o CC E:\NuMaker\rt-thread\bsp\nuvoton\libraries\nu_packages\BMX055\libraries\BMM050_driver\bmm050.o CC E:\NuMaker\rt-thread\bsp\nuvoton\libraries\nu_packages\Demo\usbd_cdc_vcom_echo.o CC E:\NuMaker\rt-thread\bsp\nuvoton\libraries\nu_packages\Demo\slcd_show_tick.o CC E:\NuMaker\rt-thread\bsp\nuvoton\libraries\nu_packages\Demo\usbd_hid_dance_mouse.o LINK rtthread.elf arm-none-eabi-objcopy -O binary rtthread.elf rtthread.bin arm-none-eabi-size rtthread.elf text data bss dec hex filename 277116 5080 57760 339956 52ff4 rtthread.elf scons: done building targets. ``` # 3 开发板烧录 主要烧录方式两种: 1. NuMicro MCU 虚拟磁盘; 2. RT-Thread Studio工具烧录。 > 这里用的是NuMicro MCU 虚拟磁盘方式,区别是要将NuMaker-IoT-M487 上的 ISW1四个开关都拨到 ‘ON’ 的位置;而RT-Thread Studio工具烧录则是ISW1前三个开关拨到 ‘ON’,第四个开关要拨到 ‘OFF’。 NuMicro MCU 虚拟磁盘的ISW1四个开关状态如下图: ![image.png](https://oss-club.rt-thread.org/uploads/20220410/56b605f91ee28821921940b02cc4b1e0.png.webp) 配置完成后,将开发板使用 Micro USB 连接线连接计算机,我的计算机将出现一个 NuMicro MCU 虚拟磁盘。 ![image.png](https://oss-club.rt-thread.org/uploads/20220410/2e40e45d2cc56d28341e55a0927ffd3b.png.webp) 将上一步编译出的rtthread.bin拷贝到该虚拟磁盘根目录,然后NuMaker M487会自动检测、升级和重启。 ``` - RT - Thread Operating System / | \ 4.1.0 build Apr 7 2022 22:24:56 2006 - 2022 Copyright by RT-Thread team This chip does not support TRNG! [I/I2C] I2C bus [i2c0] registered [I/I2C] I2C bus [i2c1] registered [I/I2C] I2C bus [i2c2] registered [W/drv.qspi] qspi0 clock max frequency is 48000000Hz (!= 50000000Hz) [I/SFUD] Find a Winbond flash chip. Size is 4194304 bytes. [I/SFUD] flash0 flash device is initialize success. [I/SFUD] Probe SPI flash flash0 by SPI device qspi01 success. [I/sal.skt] Socket Abstraction Layer initialize success. [I/utest] utest is initialize success. [I/utest] total utest testcase num: (0) Failed to mount elm on /. Try to execute 'mkfs -t elm flash0' first, then reboot. [I/at.clnt] AT client(V1.3.1) on device uart1 initialize success. [I/sensor] rt_sensor[mag_bmx055] init success [I/sensor] rt_sensor[acce_bmx055] init success [I/sensor] rt_sensor[gyro_bmx055] init success [D/FAL] (fal_flash_init:49) Flash device | OnChip_APROM | addr: 0x00000000 | len: 0x00080000 | blk_size: 0x00001000 |initialized finish. [D/FAL] (fal_flash_init:49) Flash device | OnChip_LDROM | addr: 0x00100000 | len: 0x00101000 | blk_size: 0x00001000 |initialized finish. [I/FAL] ==================== FAL partition table ==================== [I/FAL] | name | flash_dev | offset | length | [I/FAL] ------------------------------------------------------------- [I/FAL] | ldrom | OnChip_LDROM | 0x00000000 | 0x00001000 | [I/FAL] | aprom | OnChip_APROM | 0x00060000 | 0x00020000 | [I/FAL] ============================================================= [I/FAL] RT-Thread Flash Abstraction Layer initialize success. [I/dancemouse] Ready. msh />[I/at.dev.esp] esp0 device wifi is disconnect. msh />[E/at.clnt] execute command (AT+CWJAP="NT_ZY_BUFFALO","12345678") failed! [W/at.dev.esp] esp0 device wifi connect failed, check ssid(NT_ZY_BUFFALO) and password(12345678). [I/at.dev.esp] esp0 device network initialize successfully. ``` > [E/at.clnt] execute command (AT+CWJAP="NT_ZY_BUFFALO","12345678") failed!表示wifi的ssid和密码不对! # 4 AUDIO测试 ## 4.1 wavpayer组件 进入menuconfig界面,选择wavpayer组件 ``` .config - RT-Thread Configuration → RT-Thread online packages → multimedia packages → WavPlayer: Minimal music player for wav file play and record ─ ┌──────────────────────────────────────────────────┐ │ --- WavPlayer: Minimal music player for wav file play and record │ │ [*] Enable support for play (NEW) │ │ (sound0) The play device name (NEW) │ │ [*] Enable support for record │ │ (sound0) The record device name (NEW) │ │ Version (latest) ---> │ └──────────────────────────────────────────────────┘ ├──────────────────────────────────────────────────┤ │
< Exit > < Help > < Save > < Load > │ └──────────────────────────────────────────────────┘ ``` 更新组件到本地 ``` pkgs --update ``` 重新编译,生成rtthread.bin ``` scons ``` 将生成的rtthread.bin用虚拟磁盘方式烧录进去,可以看到有wavplay和wavrecord命令: ``` msh />wavplay -h usage: wavplay [option] [target] ... usage options: -h, --help Print defined help message. -s URI, --start=URI Play wav music with URI(local files). -t, --stop Stop playing music. -p, --pause Pause the music. -r, --resume Resume the music. -v lvl, --volume=lvl Change the volume(0~99). -d, --dump Dump play relevant information. msh />wavrecord -h usage: wavrecord [option] [target] ... usage options: -h, --help Print defined help message. -s file --start=file
record wav music to filesystem. -t, --stop Stop record. ``` ## 4.2 挂载elm文件系统 wavrecord录制wav文件到文件系统上,elm是fatfs文件系统。 ``` msh />mkfs -t elm flash0 msh />mount flash0 / elm mount device flash0(elm) onto / ... succeed! msh />mount filesystem device mountpoint ---------- ------ ---------- devfs (NULL) /dev elm flash0 / ``` `mkfs -t elm flash0 `: 对设备flash0制作elm文件系统 `mount flash0 / elm`: 挂载设备flash0到/节点上,该设备是elm文件系统 ## 4.3 录音测试 `wavrecord -s /test.wav 8000 2 16`: 开始录音,PCM格式为采样率8K/双通道/16bit精度,封装格式为WAV。 `wavrecord -t`:停止录音 演示: ``` msh />wavrecord -s /test.wav 8000 2 16 [I/i2s] Stop record. [I/i2s] Close I2S. [I/acodec.nau88l25] Software Reset. [I/acodec.nau88l25] Initialized done. [I/i2s] Open I2S. [W/i2s] Real sample rate: 46875 Hz != preferred sample rate: 48000 Hz [I/i2s] Start record. Information: samplerate 8000 channels 2 [I/i2s] Stop record. [I/i2s] Close I2S. [I/acodec.nau88l25] Software Reset. [I/acodec.nau88l25] Initialized done. [I/i2s] Open I2S. [W/i2s] Real sample rate: 8152 Hz != preferred sample rate: 8000 Hz [I/i2s] Start record. msh /> msh />wavrecord -t [I/i2s] Stop record. [I/i2s] Close I2S. msh />ls Directory /: test.wav 442412 ``` 通过ls命令查看到test.wav文件。 ## 4.4 播放测试 播放录音文件test.wav `wavplay -s /test.wav`: 开始播放test.wav文件,wav封装头中有音频的采样率/通道/精度,不用再指定这些参数; 演示: ``` msh />wavplay -s /test.wav [I/WAV_PLAYER] play start, uri=/test.wav [I/i2s] Stop replay. [I/i2s] Close I2S. [I/acodec.nau88l25] Software Reset. [I/acodec.nau88l25] Initialized done. [I/i2s] Open I2S. [W/i2s] Real sample rate: 8152 Hz != preferred sample rate: 8000 Hz [I/i2s] Start replay. [I/i2s] Stop replay. [I/i2s] Close I2S. [I/WAV_PLAYER] play end ``` 这里可以手动在发命令结束播放,也可以等待播放完毕。 `wavplay -t`: 结束播放; 演示: ``` msh />wavplay -s /test.wav [I/WAV_PLAYER] play start, uri=/test.wav [I/i2s] Stop replay. [I/i2s] Close I2S. [I/acodec.nau88l25] Software Reset. [I/acodec.nau88l25] Initialized done. [I/i2s] Open I2S. [W/i2s] Real sample rate: 8152 Hz != preferred sample rate: 8000 Hz [I/i2s] Start replay. msh />wavplay -t [I/i2s] Stop replay. [I/i2s] Close I2S. [I/WAV_PLAYER] play end ``` `wavplay -v 70`: 在正在播放时,可以调节音量,比如70 ``` msh />wavplay -v 70 [I/WAV_PLAYER] set volume = 70 ``` > 这里有"[I/WAV_PLAYER] set volume = 70"这句打印需要修改wavplayer.c中wavplayer_volume_set里的打印LOG_D为LOG_I。 `wavplay -p`: 暂停播放; `wavplay -r`: 恢复播放; # 5 测试结果 这里总体音频测试结果不是很理想,主要现象表现为播放时有时声音时正常的,有时都是全是噪音或变调; issue记录地址:https://github.com/RT-Thread/rt-thread/issues/5822 | 参数 | 结果(测十次) | 测试命令 | | - | - | - | | 8000/1/16 | 3次有声音(环境噪明显), 7次全噪 | wavrecord -s 8000_1.wav 8000 1; wavrecord -t; wavplay -s 8000_1.wav | | 8000/2/16 | 6次正常,4次全是噪声 | wavrecord -s 8000_2.wav 8000 2; wavrecord -t; wavplay -s 8000_2.wav| | 16000/1/16 | 5次正常,5次全是噪声 | wavrecord -s 16000_1.wav 16000 1; wavrecord -t; wavplay -s 16000_1.wav| | 16000/2/16 | 5次正常,5次全是噪声 | wavrecord -s 16000_2.wav 16000 2; wavrecord -t; wavplay -s 16000_2.wav| | 44100/1/16 | 5次变调加噪声,5次全是噪声 | wavrecord -s 44100_1.wav 44100 1; wavrecord -t; wavplay -s 44100_1.wav| | 44100/2/16 | 5次变调,5次全是噪声 | wavrecord -s 44100_2.wav 44100 2; wavrecord -t; wavplay -s 44100_2.wav| | 48000/1/16 | 1次变调加噪声,9次全是噪声 | wavrecord -s 48000_1.wav 48000 1; wavrecord -t; wavplay -s 48000_1.wav| | 48000/2/16 | 1次变调加噪声,9次全是噪声 | wavrecord -s 48000_2.wav 48000 2; wavrecord -t; wavplay -s 48000_2.wav|
0
条评论
默认排序
按发布时间排序
登录
注册新账号
关于作者
rt_wei
这家伙很懒,什么也没写!
文章
1
回答
0
被采纳
0
关注TA
发私信
相关文章
1
I2S WM8978 DMA没中断问题,参考SAI驱动改写
2
audio的replay模式播放时是先发一段0来启动吗?
3
audio的replay模式不能播放长度小于内存块大小的数据吗?
4
关于音频初始化函数感觉有问题:_audio_dev_init
5
柿饼m3模块的音频问题
6
关于rtthread支持的媒体库
7
请问vs1050的音频驱动怎么写啊?
8
RT-Thread Audio - 1. 音频框架的分析
9
1.工具:rt-thread studio ;2.MCU:stm32f407zgt6;3: audio 怎么使用?4.背景:首次使用RT-thread
10
STM32F407ZGT6音频I2S对接audio框架
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
I2C_IIC
UART
WIZnet_W5500
ota在线升级
freemodbus
PWM
flash
cubemx
packages_软件包
BSP
潘多拉开发板_Pandora
定时器
ADC
flashDB
GD32
socket
中断
编译报错
Debug
SFUD
rt_mq_消息队列_msg_queue
msh
keil_MDK
ulog
C++_cpp
MicroPython
本月问答贡献
a1012112796
9
个答案
1
次被采纳
踩姑娘的小蘑菇
4
个答案
1
次被采纳
红枫
4
个答案
1
次被采纳
张世争
4
个答案
1
次被采纳
Ryan_CW
4
个答案
1
次被采纳
本月文章贡献
catcatbing
3
篇文章
5
次点赞
qq1078249029
2
篇文章
2
次点赞
xnosky
2
篇文章
1
次点赞
Woshizhapuren
1
篇文章
5
次点赞
lizimu
1
篇文章
3
次点赞
回到
顶部
发布
问题
投诉
建议
回到
底部