UM10208_2
© NXP B.V. 2007. All rights reserved.
User manual
Rev. 02 — 1 June 2007
256 of 362
NXP Semiconductors
UM10208
Chapter 19: LPC2800 DAI
6.
Programming the DAI and SAI1
Application software can use the DAI and SAI1 in one of three modes:
1. Fully interrupt-driven. All I
2
S input data is handled via interrupts.
2. Dedicated DMA. All I
2
S input data is stored in memory by one or two dedicated
GPDMA channel(s).
3. Dynamic DMA assignment. One or two GPDMA channel(s) is/are selected and
configured when the first input arrives (in Slave mode) or when the application
determines that I
2
S input should be done (in Master mode).
6.1 Setting up the DAI and SAI1
System initialization (reset) code should include the following steps if the DAI and SAI1
are used in the application:
1. Write the desired format codes to the I
2
S Format register.
2. Write the Stream I/O Configuration register with the prescribed/fixed bits, and 1 in the
DAI_OE bit for Master mode, 0 for Slave mode.
3. In Slave mode, program the High Speed PLL to take its input from either the BCKI pin
or the WSI pin. If the ratio between the bit clock and the sampling frequency is known,
use the BCKI pin. If not, use WSI. Particularly when using WSI, note that the HS PLL
has problems locking to a frequency less than 100kHz. In Master mode, program the
HS PLL to take its input from the Main oscillator.
4. Program the CGU to provide the proper DAI clocking. In Slave mode the external I
2
S
bit clock arrives on the BCKI pin -- program the CGU to route this clock to its
DAI_XBCK output. In Master mode, program the CGU to generate the bit clock and
route it to its DAI_BCKI output, and program a fractional divider to divide that bit clock
by twice the number of bits per word in stretched mode, and route the fractional
divider output to its DAI_WS output.
5. Write the SAI1 Interrupt Request register in the interrupt controller (INT_REQ16 -
0x8030 0440) to enable SAI1 interrupts at the desired priority level (see
6. Write the SAI1 Mask register with zero(es) in the desired interrupt condition(s). For
fully interrupt-driven applications, write a 0 in one of the LNMTMK, LHALFMK, or
LFULMK
bits.
For dedicated DMA, write a 0 to LOVER to allow interrupt for overrun
(which indicates an error in DMA operation or programming). For dynamically-
assigned DMA in Slave mode, write a 0 to LNMTMK.
Since L and R values are always loaded from the DAI into SAI1 together, there is no
reason to enable both L and R interrupts. Of course the corresponding R condition(s) can
be enabled instead of the L condition(s).
6.2 Fully interrupt-driven data transfer
When an interrupt occurs and the SAI1 is the highest-priority interrupt request, the basic
interrupt service routine (ISR) transfers control to the specific ISR for the SAI1. On entry,
depending on which interrupt was enabled in step
above, the SAI1 ISR knows the
minimum number of L and R values that are available in SAI1 (1 for LNMTMK, 2 for