Debugging DMA in Ping-Pong Mode

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero Employee</font></font> </a> PhillipB on ‎03-31-2017 05:38 PM

Question

I am using the SPI Tx with DMA in ping-pong mode to transfer data from my EFM32.  The application runs perfectly.  

 

However, after I add a breakpoint (ex: in the SPI Tx Complete function) and halt the device during a debug session, when I continue/run from this point the DMA stops. What am I doing wrong?

Answer

In ping-pong mode the SPI Tx Complete function will be called as a callback function every time either the primary or the alternate descriptor is finished with its transfers. If you stop the device in debug mode, the DMA will run until both descriptors are empty - which should have triggered two interrupts.

 

However, since they share the same interrupt flag, one of the requests will be masked as the flag is already set when the second descriptor is done. When you press run again, only one of the descriptors will be re-armed and the DMA will stop (as you observed).

 

The ping-pong setup requires the callback and DMA ISR to finish before the other descriptor has finished with its transfers. As the DMA is not halted in debug, you cannot halt the CPU in this routine without causing the DMA to stop as a result.