[sdiy] DMA (was Re: Audio CODECs)
Tom Wiltshire
tom at electricdruid.net
Mon Mar 5 12:47:18 CET 2012
On 5 Mar 2012, at 04:27, Robin Whittle wrote:
> These audio codecs often use a serial digital interface called I2S. The
> 32 bit PIC microcontrollers I mentioned have a serial interface which
> can support this, with First In First Out (FIFO) buffers so nothing is
> lost if the CPU can't read or write the data in time. Generally,
> however, this interface would be fed by a DMA controller, with the CPU
> running software to read and write the audio samples in circular buffers
> in RAM, as the DMA tracks along these buffers and the FIFOs handle the
> last moment timing of sending the samples one after the next to the DAC
> of the CODEC and receiving likewise from the ACD part.
>
> - Robin
When you get this DMA transfer set up for the first time, it's a thing of beauty!
On the dsPIC (don't know about the 32MX - haven't used those) you can have the DMA transfer samples from a buffer to the DAC without any overhead. It just does it in the background. When the buffer is empty, it sets a flag and switches over to a second buffer (Ping Pong mode!) and starts on that. In the main code, you check the flag, and if it's set, you process some more samples and refill the empty buffer. This kind of block processing is much quicker than "one in, one out". Although its a bit more complicated to set up initially, it's no more difficult to do.
T.
More information about the Synth-diy
mailing list