AnsweredAssumed Answered

STM32F303 - disabling DMA during transfer

Question asked by jcp on Mar 21, 2013
Latest reply on Mar 22, 2013 by waclawek.jan
I'm having difficulty getting deterministic behavior when disabling a DMA transfer in progress.  I'm using DMA to feed the USART 2 transmitter from a buffer.  When I need to queue up more data for the transmitter, I'd like to
       
  • disable the DMA channel
  •    
  • use the DMA channel counter (CNDTR) to determine how many bytes were sent
  •    
  • shift the remaining bytes to the start of the buffer and append the new bytes
  •    
  • setup the DMA controller to transfer the new buffer and enable it.
I'm getting repeated (and occasionally missing) bytes out the USART using this method, as if CNDTR is not reliable after disabling a transfer in progress.  I can't seem to find any documentation on what to expect when disabling a DMA channel in the middle of a transfer.

Can this be done in a deterministic way?
Is there a flag or indication I should wait for after disabling the DMA channel? (Note that Transfer Complete is not set after the channel is disabled).
Most interesting thing:  This same code worked with the STM32F103.

-jcp

Outcomes