I have implemented a ring buffer using UART interrupt. Basically my code continually fills the ring buffer and when an endline character is read, it sets a flag to indicate a new message has been received.
I am wondering if I can achieve the same thing using the DMA controller?
DMA interrupts are usually based on the number of bytes transferred, normally half-complete and complete. There's no mechanism to check the content of each received byte during a DMA transaction.
You might be able to do it with a combination of "double buffer mode" and a timer...
The problem is I would still need to scan through the buffers with the processor if there's not a way to get the DMA controller to trigger it. For my application it becomes kind of pointless I guess.
As a secondary question(and I can make a new thread), do you know how to get sprintf to work with decimals? I'm using the arm GCC C library with atmel studio 7 and I can't print floating point numbers, some type of error gets triggered and the program crashes to a default handler.
It is true, DMA is much faster than an interrupt driven routine. Your post makes me wonder two things. Is this application close to the limit of available processing time? The other thing, understand that in some systems, DMA and CPU share memory transparently, and others not. Some have a crossbar matrix such that both DMA and CPU can actually complete access cycles simultaneously, or nearly so. But some have contention for memory, in which case DMA will still impact CPU time, just not to such a large extent. By its nature, it takes priority.
Your other question will have to be sorted out some way, I suspect you need to inspect your DMA stream much less than you think. Try to remove whatever impediment created that need.
Secondary question, it seems to me a separate thread would be most logical. Include the code and error listing verbatim.
I think I figured out a way to do it, the USART has an RX time out interrupt, you can probably do something where your end-message signal can be triggered via that. The DMA can't be configured to use a ring buffer(STM parts can but they are way newer - idk why the due still on M3), probably the only option is having two buffers and switching the DMA between them when one is full. This will mess up your max message length though.