Forum Discussion
Altera_Forum
Honored Contributor
20 years agoAborting a DMA transfer
I'm looking for a way to abort a DMA transfer without using the flow control. I'm blown away that there's not a control bit in the DMA controller to abort a transfer! We have a peri...
Altera_Forum
Honored Contributor
20 years agoI think all you have to do is clear the "GO" bit in the command register. I just realized that I was missing that functionality in my DMA routines (for a USB chip) so I added a function like this:
int AbortUSBTransfer()
{
if ((IORD_ALTERA_AVALON_DMA_STATUS(DMA_0_BASE) & ALTERA_AVALON_DMA_STATUS_BUSY_MSK) == 0)
return 1; // nothing to do
// clear control register (mainly clear "GO" bit
IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_0_BASE, 0);
if ((IORD_ALTERA_AVALON_DMA_STATUS(DMA_0_BASE) & ALTERA_AVALON_DMA_STATUS_BUSY_MSK) == 0)
return 1; // abort worked
else
return -1; // abort failed
} I just tried it and it seems to work. I started a DMA transfer but didn't send any data from the PC. I then aborted the DMA transfer and the DMA engine went back to idle (busy and done bit cleared). After that I executed some more DMA transfers and they worked fine. Hope that helps, Andrew