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?


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.

  • Knowledge Base Articles
  • 32-bit MCUs