22.6.6. DAO_I2S_DMA
22.6.6.1. Overview
This example demonstrates the functionality of using DAO (Digital Audio Output) + I2S peripheral with DMA to transfer audio data for playback. DAO is a digital audio output module that can directly output differential PWM signals to drive CLASSD amplifier chips for audio playback. This example also supports pause and resume functionality through GPIO button control.
22.6.6.2. Workflow
Configure system audio clock (MCLK) according to the audio sampling rate
Initialize I2S peripheral and DAO peripheral:
Configure I2S peripheral, including audio data format (bit width, channels, sampling rate)
Enable I2S DMA transmit request
Configure DAO peripheral
Configure GPIO button interrupt for controlling audio playback pause and resume:
Set button interrupt trigger condition
Configure button debounce handling
Enable GPIO interrupt
Configure DMA to transfer audio data:
Configure DMAMUX, select I2S as DMA request source
Enable DMA interrupt
Set source address to audio data storage location
Set destination address to I2S transmit FIFO
Configure transfer size and width
Configure burst transfer mode (mono: DMA_NUM_TRANSFER_PER_BURST_1T; stereo: DMA_NUM_TRANSFER_PER_BURST_2T)
Start I2S peripheral and DAO peripheral:
Software reset I2S peripheral and DAO peripheral
Start I2S peripheral and DAO peripheral
DMA automatically transfers audio data to I2S TX FIFO, DAO converts I2S data and outputs
Stop I2S peripheral and DAO peripheral after DMA completion
Repeat steps 4-7 to achieve audio loop playback
Support pause/resume playback through button during audio playback
22.6.6.3. Audio Configuration
Audio format configuration
Support multiple audio sampling rates
Support 16-bit and 32-bit audio depth
Support mono (requires HPM_IP_FEATURE_DAO_AUDIO_MONO_FIX) and stereo modes
Select audio data source based on compile options:
Mono mode:
audio_mono.hStereo mode:
audio_stereo.h
Channel configuration
channel_slot_mask values
Left channel: 0x1
Right channel: 0x2
Stereo: 0x3
DAO channel parameter must be configured as dual-channel (channel_slot_mask = 0x3)
To play mono audio source with DAO, use I2S channel_slot_mask when supported
Requires HPM_IP_FEATURE_DAO_AUDIO_MONO_FIX
Set I2S channel_slot_mask to mono: 0x1 plays on DAO left, 0x2 plays on DAO right
If HPM_IP_FEATURE_DAO_AUDIO_MONO_FIX is not supported, duplicate mono data to form stereo and play as stereo
To play stereo audio source with DAO, set I2S channel_slot_mask = 0x3 so both left and right output
22.6.6.4. Hardware Settings
Connect a speaker to the development board’s DAO interface for audio playback
Use the development board’s button button interface for controlling playback pause/resume
22.6.6.5. Known Issues
Some audio may produce noise when played through DAO
On-board buttons may trigger multiple GPIO interrupts due to mechanical bounce
22.6.6.6. Running the Example
When the project runs correctly, you should observe:
Terminal output:
DAO_I2S with DMA example DAO_I2S with DMA play test start, press button can pause/resume audio play. DAO_I2S with DMA play one cycle finished DAO_I2S with DMA play one cycle finished DAO_I2S with DMA play one cycle finished DAO_I2S with DMA play one cycle finished Test DAO_I2S DMA play success
The audio device will play the sample audio in a loop (4 times total)
Press the button during audio playback to pause, press again to resume
Terminal will display corresponding control information:
“dao_i2s pause” - pause playback
“dao_i2s resume” - resume playback