I
selected an I2S standard interface for the audio
interface because of its popularity (a number
of codec chips available from different manufacturers).
It’s also easy to interface to the microcontroller.
Some
audio DACs like the Texas Instruments TLV320DAC26
need extra control signals when initially setting
up their internal registers in addition to I2S
signals and MCLK. With simple DACs like the
Cirrus Logic CS4330-KS, for example, no setup
is required. I have tried both of them. Figure
2 shows the circuit for both options.
I
used SPI0 lines shared with the SD card and
an extra select line for the Texas Instruments
DAC control interface. Although it needed 16-bit
data, I used two consecutive transfers of 8
bits and it worked fine.
For
some extra complexity of control interface,
the chip has a built-in headphone amplifier,
as well as programmable volume control and other
controls. It also has an internal PLL, which
gives you flexibility for selecting the external
clock.
For
an MCLK signal, you can use the microcontroller’s
crystal (directly or through a buffer) or generate
it inside the microcontroller, as I did. The
code within the init_hardware() function in
the mp.c file on the Circuit Cellar FTP site
is used for the BCLK signal to be generated
on pin PWM5 (P0.21/PWM5 pin 1).