The SSP
provides a continuous stream of 16-bit data
for the audio DAC. The presence of the eight-frame
FIFO and the Tx FIFO half empty interrupt makes
for an easy data-loading scheme (see Listing 1).
I
created a large buffer for storing PCM data
that acts as a circular buffer. One pointer
manages the writing into the SSP transmit FIFO
(and later audio DAC). Another pointer manages
the loading of new data from the SD card. For
uncompressed audio files on input, the loading
comes directly from the WAV file. For MP3 files,
the data has to be decoded beforehand.
The
simple synchronization is achieved by checking
the distance between pointers with software.
The software functions related to the SSP are
the initial setup, ISR, and buffer loading functions.
(The SSP’s receive function isn’t used at all,
so the Rx of the at least half full interrupt
is disabled.)