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 peripheral that can fail before transferring the entire data packet and need a way to be able to abort/reset the DMA controller. It currently does *not* use flow control and we'd rather not have to add it and the associated logic just to be able to abort a DMA. Regards, Mark1 Reply
- Altera_Forum
Honored Contributor
I 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:
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, Andrewint 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 }