Most
audio DACs require an I2S or a similar (left-
or right-justified) data interface. The LPC2148
microcontroller has two SPIs, but neither of
them works in I2S mode. Only one of them (the
SPI1 or SSP) is capable of processing the 16-bit
data required by the I2S interface. That means
you have to use it and do some modification
to convert to I2S.
The
microcontroller’s SSP is used in a 16-bit Texas
Instruments DSP mode to make it easy to convert
into I2S. Refer to Philips’s “LPC214x User Manual”
for a description of the possible modes of operation.
A
few steps are involved with converting from
DSP mode to I2S. The data output from SPI1 doesn’t
need any modifications to be used as I2S data.
The left/right clock (LRCK) can be derived from
the FS signal in the straightforward manner.
The FS signal, which is output on the SSEL1
pin (P0.20/SSEL1 pin55) in TI mode, is connected
to the Timer1 input capture pin (P0.10/CAP1.0
pin 35). Using the timer’s one input capture
and output match function, the FS signal on
the input pin of Timer1 (P0.10/CAP1.0 pin 35)
is converted into an output signal on pin MAT1.0
(P0.12/MAT1.0), which represents the LRCK signal
of the I2S interface.
To
complete the I2S interface, the clock must be
inverted. This is achieved via the tiny logic
inverter (e.g., a Fairchild Semiconductor NC7SZ04).
Connect the inverter’s input to SCK1 (P0.17/SCK1
pin 47) and its output to BCLK on the I2S.
If
you use another DAC with a left- or right-justified
format instead of I2S, you can achieve it by
slightly changing the I2S modification because
they are similar. All of the settings of the
internal modules are done once after power-on
reset. The code is in the init_hardware() function
in the mp.c file. If you plan to use any of
the low-power modes, you might need to stop
some modules and activate them later during
wakeup. If you want to save valuable resources
like Timer1 and PWM5 for other purposes, you
can use a simple D-latch (e.g., the TinyLogic
NC7SZ74) to do the same in hardware.