This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5419 - Stopping DMA transfer

How to properly stop a DMA transfer ?

User's Guide extract:

"9.2.5 Stopping DMA Transfers
There are two ways to stop DMA transfers in progress:
• A single, block, or burst-block transfer may be stopped with an NMI, if the ENNMI bit is set in register
DMACTL1.
• A burst-block transfer may be stopped by clearing the DMAEN bit"

 

In my case, I use the single transfer mode.So, I have to trigger an NMI ? How to do that ?

FYI, I use the DMA for UART sending. I need to stop the DMA transfer for handshaking consideration.

 

  • In single transfer mode, there is only one transfer per trigger impulse. If the trigger comes, the transfer is done 4 MCLK cycles later. That's one or two assembly instructions (which do not occur since the CPU is halted during the transfer).
    If you want to halt further transfers, you can simply deactivate the DMA. Clear the DMAEN bit, stop the trigger for appearing, whatever.
    This won't stop a DMA transfer as no DMA transfer is running.

    The cited guide extract refers to ongoing DMA transfers. Once a block or burst block transfer sequence is started, it will continue with maximum speed. One transfer every 4 MCLK cycles until all transfers are done. Disabling the trigger won't stop the sequence as it has already been triggered and continues without further triggering.
    Also, in block transfer, the CPU is frozen until the sequence completes. No running CPU, so no way to stop the transfer by software. The only thing that can halt the DMA now is an NMI, caused by external hardware (or internal hardware output to a port pin and routed to the NMI pin). In burst block transfer mode, the CPU will interleave with the DMA, so it may stop the sequence (if it is long enough and not already finished before) by clearing the DMAEN bit.

  • Hi Said,

    As JMG noted, you can stop the DMA sequence simply by clearing the DMAEN bit or by stopping the triggers etc.  In your case you aren't really trying to interrupt an actual DMA transfer, so your quote from the manual doesn't really apply to your situation.

    In your case, I would not clear the DMAEN bit.  Instead, I would enable the transmit interrupt (TXIE) in the UART.  This prevents the DMA from seeing TXIFG as a trigger, and it further allows you to use the TX interrupts to send your out-of-band data (if any).  Finally, it allows the DMA controller to "remember" where it was in the transfer so you can easily resume the in-band transfer by disabling the interrupt (TXIE) again.

    Maybe that approach will fit your application.

    Jeff

  • Hi Jeff,

    Thanks you very much for your answer. It's working very well !

    I would like to thank Mr Gross too for his very interesting explanations.

    Saïd

**Attention** This is a public forum