Audio Capture
PDM microphone capture with RMS/peak statistics streamed over SWO.
| Declared by the example author | Value |
|---|---|
| Tier | Capabilities |
| Status | tested |
| Capabilities | audio, pdm |
| Boards tested | apollo510_evb |
Build it from a source checkout by name, because the positional app argument resolves
under ./examples:
nsx build audio_capture --board apollo510_evbThe rest of this page is the example’s own README, from
examples/audio_capture/.
Demonstrates nsx-audio on the Apollo510 EVB. Configures the PDM microphone at 16 kHz, captures 30 ms audio frames, and prints peak amplitude to SWO every 100 frames (~3 seconds).
Build & Run
Section titled “Build & Run”nsx configure --app-dir .nsx build --app-dir .nsx flash --app-dir . # requires EVB with onboard PDM micnsx view --app-dir . # opens SWO viewerExpected Output
Section titled “Expected Output”The SWO viewer will print once at startup, then peak amplitude every 100 frames (~3 s at 16 kHz / 480 samples per frame):
Audio system initializedAudio capture started: 16000 Hz, 1 ch, 480 samples/frameFrame 100 peak=1842Frame 200 peak=2105Frame 300 peak=947Frame 400 peak=3210Peak values depend on ambient noise. Silence gives values near 0; speaking near the mic gives values in the thousands (int16 range).
How It Works
Section titled “How It Works”- Initializes the board, caches, and SWO with
nsx_system_init()in low-power CPU mode, then configures the PDM peripheral viansx_audio_init() - DMA transfers 480-sample (30 ms) frames into a ping-pong buffer
- Enables master interrupts and checks
nsx_audio_start()before capture; a callback fires per frame and the main loop computes peak amplitude - DMA buffers use
NSX_MEM_SRAM_BSSplacement — the DMA engine on Apollo5 cannot access TCM
Hardware Notes
Section titled “Hardware Notes”- The Apollo510 EVB has an onboard PDM MEMS microphone
- No additional hardware or wiring is needed
- PDM clock and data pins are set by the EVB board definition
Troubleshooting
Section titled “Troubleshooting”If you see bootloader messages but no Frame ... peak=... readings, rebuild
and flash this example before reopening nsx view. Core API initialization
alone does not initialize the board hardware; the example uses full system
initialization before enabling PDM capture. Audio init/start failures print a
numeric status instead of claiming capture started successfully.
The viewer may attach after the startup messages have already been emitted. Leave it open for the periodic frame readings.