XAF USB Example
Table of Content
Overview
The dsp_xaf_usb_demo application demonstrates audio processing using the DSP core, the Xtensa Audio Framework (XAF) middleware library.
As shown in the table below, the application is supported on several development boards and each development board may have certain limitations, some development boards may also require hardware modifications or allow to use of an audio expansion board. Therefore, please check the supported features and Hardware modifications section before running the demo.
Feature | DMIC → USB2.0 | USB2.0 → Line out |
---|---|---|
EVK-MIMXRT595 | OK | OK |
EVK-MIMXRT685 | OK | OK |
MIMXRT685-AUD-EVK | OK | OK |
MIMXRT700-EVK | OK | OK |
Functionality
The application includes the following main components:
ARM Core (CM33) - Handles user interface, and communicates with the DSP core
DSP Core - Processes audio data using the Xtensa Audio Framework (XAF)
The XAF USB example demonstrates DSP-powered USB audio processing in two configurations: USB speaker and USB microphone. The application uses shell commands to switch between modes, with the ARM core handling USB communication while the DSP processes audio.
USB Speaker Mode (USB2.0 → Line out): Receives audio from a USB host, processes it on the DSP, and outputs through the headphone jack, making the device function as a USB speaker for your computer.
USB Microphone Mode (DMIC → USB2.0): Captures audio from the onboard digital microphones, processes it on the DSP, and streams it to a USB host as a standard audio input device.
Hardware Requirements
Development board (one of the following):
EVK-MIMXRT595 board
EVK-MIMXRT685 board
MIMXRT685-AUD-EVK board
MIMXRT700-EVK board
2x Micro USB cable
JTAG/SWD debugger
Headphones with 3.5 mm stereo jack
Personal Computer
Hardware Modifications
Some development boards need some hardware modifications to run the application.
EVK-MIMXRT595:
To enable the example audio using WM8904 codec, connect pins as follows:
JP7-1 <–> JP8-2
Note: The I3C Pin configuration in pin_mux.c is verified for default 1.8V, for 3.3V, need to manually configure slew rate to slow mode for I3C-SCL/SDA.
EVK-MIMXRT685:
To enable the example audio using WM8904 codec, connect pins as follows:
JP7-1 <–> JP8-2
MIMXRT685-AUD-EVK
Set the hardware jumpers (Tower system/base module) to default settings.
Set hardware jumpers JP2 2<–>3, JP44 1<–>2 and JP45 1<–>2.
MIMXRT700-EVK:
Set the hardware jumpers to default settings.
Preparation
Connect headphones to Audio HP / Line-Out connector.
EVK-MIMXRT595 - J4
EVK-MIMXRT685 - J4
MIMXRT685-AUD-EVK - J4
MIMXRT700-EVK - J29
Connect the first micro USB cable between the PC host and the debug USB port on the development board.
EVK-MIMXRT595 - J40
EVK-MIMXRT685 - J5
MIMXRT685-AUD-EVK - J5
MIMXRT700-EVK - J54
Connect the second micro USB cable between the PC host and the USB port on the development board.
EVK-MIMXRT595 - J38
EVK-MIMXRT685 - J7
MIMXRT685-AUD-EVK - J7
MIMXRT700-EVK - J40
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program for CM33 core to the target board.
Launch the debugger in your IDE to begin running the demo.
If building release configuration, start the xt-ocd daemon and download the program for DSP core to the target board. If building debug configuration, launch the Xtensa IDE or xt-gdb debugger to begin running the demo.
Notes:
DSP image can only be debugged using J-Link debugger. See the document ‘Getting Started with Xplorer’ for your particular board for more information.
Running the Demo
The ARM application will power and clock the DSP, so it must be loaded prior to loading the DSP application. The DSP application can be built by the following tools: Xtensa Xplorer or Xtensa C Compiler. Application for Cortex-M33 can be built by the other toolchains listed in MCUXpresso SDK Release Notes.
The release configurations of the demo will combine both applications into one ARM image. With this, the ARM core will load and start the DSP application on startup. Pre-compiled DSP binary images are provided under dsp/binary/ directory. If you make changes to the DSP application in release configuration, rebuild ARM application after building the DSP application. If you plan to use MCUXpresso IDE for cm33 you will have to make sure that the preprocessor symbol DSP_IMAGE_COPY_TO_RAM, found in IDE project settings, is defined to the value 1 when building release configuration.
The debug configurations will build two separate applications that need to be loaded independently. DSP application can be built by the following tools: Xtensa Xplorer or Xtensa C Compiler. Required tool versions can be found in MCUXpresso SDK Release Notes for the board. Application for cm33 can be built by the other toolchains listed there. If you plan to use MCUXpresso IDE for cm33 you will have to make sure that the preprocessor symbol DSP_IMAGE_COPY_TO_RAM, found in IDE project settings, is defined to the value 0 when building debug configuration. The ARM application will power and clock the DSP, so it must be loaded prior to loading the DSP application.
In order to debug both the Cortex-M33 and DSP side of the application, please follow the instructions:
It is necessary to run the Cortex-M33 side first and stop the application before the DSP_Start function
Run the xt-ocd daemon with proper settings
Download and debug the DSP application
In order to get TRACE debug output from the XAF it is necessary to define XF_TRACE 1 in the project settings. It is possible to save the TRACE output into RAM using DUMP_TRACE_TO_BUF 1 define on project level. Please see the initialization of the TRACE function in the xaf_main_dsp.c file. For more details see XAF documentation.
Running on CM33
When the demo runs successfully, the CM33 terminal will display the following output (example from MIMXRT700-EVK):
******************************
DSP audio framework demo start
******************************
[CM33 Main] Configure codec
[DSP_Main] Cadence Xtensa Audio Framework
[DSP_Main] Library Name : Audio Framework (Hostless)
[DSP_Main] Library Version : 3.5
[DSP_Main] API Version : 3.2
[DSP_Main] start
[DSP_Main] established RPMsg link
[CM33 Main] DSP image copied to DSP TCM
[CM33 Main][APP_DSP_IPC_Task] start
[CM33 Main][APP_Shell_Task] start
Copyright 2024 NXP
>>
Type help
to see the command list. Similar description will be displayed on serial console (example from MIMXRT700-EVK):
"help": List all the registered commands
"exit": Exit program
"version": Query DSP for component versions
"usb_speaker": Perform usb speaker device and playback on DSP
USAGE: usb_speaker [start|stop]
start Start usb speaker device and playback on DSP
stop Stop usb speaker device and playback on DSP
"usb_mic": Record DMIC audio and playback on usb microphone audio device
USAGE: usb_mic [start|stop]
start Start record and playback on usb microphone audio device
stop Stop record and playback on usb microphone audio device
When usb_speaker command starts playback successfully, the terminal will display following output:
[APP_DSP_IPC_Task] response from DSP, cmd: 21, error: 0
DSP USB playback start
>>
Xtensa IDE log when command is playing a file:
USB speaker start, initial buffer size: 960
[DSP_USB_SPEAKER] Audio Device Ready
[DSP_USB_SPEAKER] post-proc/pcm_gain component started
[DSP_USB_SPEAKER] post-proc/client_proxy component started
[DSP_USB_SPEAKER] Connected post-proc/pcm_gain -> post-proc/client_proxy
[DSP_USB_SPEAKER] renderer component started
[DSP_USB_SPEAKER] Connected post-proc/client_proxy -> renderer
[DSP_ProcessThread] start
[DSP_BufferThread] start
[DSP_CleanupThread] start
The USB device on your host will be enumerated as XAF USB DEMO.
Xtensa IDE will not show any additional log entry.
Running the demo DSP
Debug configuration: When the demo runs successfully, the terminal will display the following:
Cadence Xtensa Audio Framework
Library Name : Audio Framework (Hostless)
Library Version : 2.6p1
API Version : 2.0
[DSP_Main] start
[DSP_Main] established RPMsg link
Known Issues
When starting the “usb_speaker” after the “usb_mic” command, the sound output may be distorted. Please power cycle the board.