cancel
Showing results for 
Search instead for 
Did you mean: 

Problem on using USART with DMA

sonyoungbin
Associate
Posted on January 01, 2013 at 20:52

Hello,

I am implementing a UART driver using circular queue scheme, and found a minor problem with it.

When I put a new character after DMA channel 5 finishes its transfer - i.e. put a new character when DMA_CNDTR5=0 - the DMA(not just ch5, including channel 4, which runs for UART TX) stops working.

It can be solved by disabling DMA channel quickly after its finish, before any new request arrives.

However, due to many problems, such as latency due to interrupt priority, I think some error may occur using this method, so I changed channel 5 to use circular mode, which makes CNDTR never turn to 0.

It doesn't make such problems, but it overwrites unread data.

Is there any method that can disable a dma channel after its transfer completion automatically?
1 REPLY 1
Posted on January 02, 2013 at 02:43

What part, baud rates and usart are we talking about here? It's easier to work with specifics.

I'd think with a reasonably small circular DMA Rx buffer (say 32 or 64 bytes) with an HT and TC interrupt, you'd be able to deal with some quite significant latency.

For Tx, I can't see why one would use circular DMA, but rather chain linear buffers at the TC interrupt. You'd basically be able to stream if the latency was less than around 16-20 bit times.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..