2013-03-18 07:24 AM
Hello,
I am working on a device which one funcion should be USART to Ethernet bridge on STM32F407. I need to receive data from USART and then work with them. But beacuse of speed I wanted to use DMA instead of interrupt after every received byte. The problem is, that I don�t know, how long will be received data=>I can�t set DMA to receive fixed number of bytes and then generate interrupt. So figured out one solution: I will configure DMA to transfer received byte from USART everytime, when it will be received. DMA will use double buffer mode. Then, I will create some timeout function which will be called periodically after some time. This function will always switch DMA to the second buffer and then read data from the first buffer and work with them. Is it possible? Could be a problem if I will be switching to the second DMA buffer at the same time as the DMA transfer will be working(It will be moving byte from USART rx buffer to memory )? (I know, that it is not very probably, but I need my device very reliable.) Or is there any better solution? Thank you #double-buffer #dma #dma-usart2013-03-18 07:32 AM
Doing it a byte at a time doesn't solve any issues with respect to speed.
Use a reasonably large circular DMA buffer, generate interrupts on HT and TC conditions, track where the DMA pointer is, and have a secondary timeout interrupt to collect runt byte(s)2013-03-18 07:41 AM
Alternatively have a large circular DMA buffer, have an interrupt run at about twice the fill rate, and have that periodic interrupt flush between the last and current fill points of this ring buffer.
2013-03-18 07:55 AM
Good idea. Thank you
2013-03-18 08:41 AM
there is an App Note that uses timer input to detect when there is no activity on the RX line.
it fires an interrupt and one can stop the DMA, gather data, restart DMA.works well for burst or message type communication.