lpcware

DMA Ping-Pong DAC Output

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by lsimons on Wed May 07 12:48:58 MST 2014
I am trying to output procedurally generated audio using the GPDMA and the DAC in a ping-pong transfer scheme.  To do this, I've created to linked list items and configured DMA Ch. 0 to output them:

dac_transfer_a - Source dac_buffer_a, Next item dac_transfer_b
dac_transfer_b - Source dac_buffer_b, Next item dac_transfer_a

I can set the contents of the dac_buffers before enabling the DMA, and I can see the expected voltages at the DAC.

In order to update the DAC buffers, I've enabled the Terminal Count Interrupt, and determine which buffer is free by looking at the next linked list item.  I thought that since I have just finished transfering, the buffer for the next linked item (DMACCLLI) is busy, and the current transfer's buffer is available.


void DMA_IRQHandler() {
uint32_t* free_dac_buffer;

if (LPC_GPDMA->DMACIntTCStat & (1<<0)) {

if (LPC_GPDMACH0->DMACCLLI == &dac_transfer_a) {
free_dac_buffer = dac_buffer_b;
} else {
free_dac_buffer = dac_buffer_a;
}

               update_buffer(free_dac_buffer);

LPC_GPDMA->DMACIntTCClear = 1 << 0;
}
}


However, I realized I'm assuming that DMACCLLI points at the transfer just completed, and is not immediatly advanced.  I couldn't find anything definitive in the datasheet, and was hoping to get confirmation on the right way to handle this kind of transfer.

Thank you,
Louis

Outcomes