Hi all,
I am having difficulties reading microphone data using built-in microphone at Xiao Seeed nRF52840 Sense. I have configured the overlay file as suggested here. Then used one of the examples - https://gist.github.com/hlord2000/52949ffc1650bb91f2170a4ac160ebae. The project file includes the following switches:
CONFIG_GPIO=y CONFIG_FPU=y CONFIG_PWM=y # Enable audio subsystem CONFIG_AUDIO=y CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED=y CONFIG_AUDIO_DMIC=y # Enable Logging and RTT Backend CONFIG_LOG=y
The code is compiled ok
west build --build-dir /Users/jaroslavpsenicka/Projects/nrf/blinky/build /Users/jaroslavpsenicka/Projects/nrf/blinky --pristine --board xiao_ble/nrf52840/sense --sysbuild -- -DCONF_FILE="prj.conf" -DDTC_OVERLAY_FILE=boards/seeed_xiao_nrf52840.overlay
...
-- Zephyr version: 4.1.99 (/opt/nordic/ncs/v3.1.1/zephyr), build: ncs-v3.1.1
[181/181] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 66084 B 788 KB 8.19%
RAM: 45824 B 256 KB 17.48%
IDT_LIST: 0 GB 32 KB 0.00%
Generating files from /Users/jaroslavpsenicka/Projects/nrf/blinky/build/blinky/zephyr/zephyr.elf for board: xiao_ble
Converted to uf2, output size: 132608, start address: 0x27000
Wrote 132608 bytes to zephyr.uf2
[10/10] Generating ../merged.hex
and flashed using my Raspberry Pico-based OCD
openocd -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c "program build/merged.hex verify" -c "reset run"
When executed, the microphone does not react to sound and produces output like so:
[00:51:40.001,464] <inf> dmic_sample: RMS: 0.015731 [00:51:40.101,470] <inf> dmic_sample: RMS: 0.015731 [00:51:40.201,477] <inf> dmic_sample: RMS: 0.015731 [00:51:40.301,483] <inf> dmic_sample: RMS: 0.015731
The code runs OK and I can attach the debugger and control the execution, however, the data seems to be stale - after a short period right after the restart:
[00:00:01.330,841] <inf> dmic_sample: RMS: 0.029410 [00:00:01.430,847] <inf> dmic_sample: RMS: 0.023021 [00:00:01.530,853] <inf> dmic_sample: RMS: 0.019408 [00:00:01.630,828] <inf> dmic_sample: RMS: 0.017508 [00:00:01.730,865] <inf> dmic_sample: RMS: 0.016566 [00:00:01.830,841] <inf> dmic_sample: RMS: 0.016117 [00:00:01.930,847] <inf> dmic_sample: RMS: 0.015907 [00:00:02.030,853] <inf> dmic_sample: RMS: 0.015811 [00:00:02.130,828] <inf> dmic_sample: RMS: 0.015767 [00:00:02.230,865] <inf> dmic_sample: RMS: 0.015746 [00:00:02.330,780] <inf> dmic_sample: RMS: 0.015738 [00:00:02.430,786] <inf> dmic_sample: RMS: 0.015733 [00:00:02.530,822] <inf> dmic_sample: RMS: 0.015731 [00:00:02.630,859] <inf> dmic_sample: RMS: 0.015731 [00:00:02.730,834] <inf> dmic_sample: RMS: 0.015731
I briefly experiemented with the regulator feature - assuming the microphone is not properly powered - is uses pin P1.10 to power the mic, as can be seen here: https://files.seeedstudio.com/wiki/XIAO-BLE/Seeed-Studio-XIAO-nRF52840-Sense-v1.1.pdf. However, adding an alias and explicitly enablig the regulator did not make any difference.
aliases {
mic-reg = &{/msm261d3526hicpm-c-en};
};
and the code
const struct device *const dmic_dev = DEVICE_DT_GET(DT_NODELABEL(dmic_dev));
static const struct device *mic_reg = DEVICE_DT_GET(DT_ALIAS(mic_reg));
int ret;
LOG_INF("DMIC sample");
if (!device_is_ready(dmic_dev)) {
LOG_ERR("%s is not ready", dmic_dev->name);
return -ENODEV;
}
regulator_enable(mic_reg);
k_sleep(K_MSEC(50)); /* REQUIRED for this mic */
So I wonder whether some of you nRF gurus have tried using the built-in microphone with this board.
Could be a hardware problem? My next attempt is probably an external microphone, which might be a little bit over my head, to be honest.
Thank you in advance,
Jaroslav