Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Aborting a DMA transfer

Altera_Forum
Honored Contributor II
897 Views

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, 

Mark
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
186 Views

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: 

 

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
0 Kudos
Reply