2013-03-20 08:08 PM
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
2013-03-21 03:28 AM
> Is there a flag or indication I should wait for after disabling the DMA channel?
While the description of the 'F3 DMA is different from the 'F2/'F4, I'd risk a guess that they stem from the same root. Thus, I'd try the procedure outlined in the 'F2/'F4 manual, namely after writing zero to ENABLE bit, reading it back until it reads zero. > (Note that Transfer Complete is not set after the channel is disabled). Did you check that? If it's true the DMA units are similar, it should be set (after EN readback goes to zero as described above). JW2013-03-21 07:18 AM
Seems like a lot of unnecessary faffing around, why not just chain another DMA transaction when you get the TC interrupt?
2013-03-21 01:10 PM
That is probably what I'll end up having to do. I've already verified that waiting for each transfer to complete results in correct operation. I was trying to avoid rewriting existing code and having (what I feel is) the added complexity of additional ISRs in my application. It would also be reassuring to know that DMA transfers can be interrupted with predictable results.
This evening, I'll try the suggestions made by JW before embarking on a rewrite. -jcp2013-03-21 09:19 PM
So, here is the scoop. When the DMA channel is disabled by clearing the EN bit in its CCR register during a transfer, the bit is cleared immediately. At least, it is always faster than the few cycles it takes for a single branch and read of the CCR register (that is how the C compiler generated it). Also, when the DMA channel is disabled during a transfer in this way, the Transfer Complete Flag is not set in IFCR. All of this would be fine if CNDTR could be used to correctly calculate the number of bytes transferred. But it seems that is not the case.
Just for reference, I'm running the STM32F303 (Rev Y) at 60Mhz (PLL driven from HSI) with APB1 and APB2 at 30MHz. USART2 is transmitting at 115200. Now, on to a different implementation. -jcp2013-03-22 12:21 AM
So it appears that the 'F3 DMA unit is indeed different from the 'F2/'F4. Thanks for letting us know that.
JW