2013-05-20 01:38 PM
I am using a STM32F407 and have set it up for using USART with DMA.
I have some problems with the RX part. What is the best way to sync the enabling of the RX DMA with the remote transmitter? If I enable it in the middle of a transmission, only part of the message will fill the buffer and I will get the TC interrupt during transmission of next message. Or if I enable it when the transmitter is idle but some garbage is clocked in, for instance a break symbol when the transmitter is reset, I will get one byte offset in my buffer and the interrupt will fire too early.What is the best way to tackle this? #usart-dma #stm32f4-dma-usart2013-05-20 01:59 PM
I would be tempted to turn the thing on it's head, use a circular DMA buffer, pull content via HT/TC, and have a timeout, along with a protocol that was robust to resynching. ie had some preamble and structure.
I'd imagine you could set up the DMA transfer ahead of time, and then engage USART_DMACmd(USARTx, USART_DMAReq_Rx, ENABLE); when RXNE was clear, or wait for the first byte via an RXNE interrupt and then light off the remainder. Can you describe the protocol interaction that elicits the received data?From: frank bolatoli / peter eckstrandPosted: Monday, May 20, 2013 10:38 PMSubject: Syncing USART/DMA RXI am using a STM32F407 and have set it up for using USART with DMA.
I have some problems with the RX part. What is the best way to sync the enabling of the RX DMA with the remote transmitter? If I enable it in the middle of a transmission, only part of the message will fill the buffer and I will get the TC interrupt during transmission of next message. Or if I enable it when the transmitter is idle but some garbage is clocked in, for instance a break symbol when the transmitter is reset, I will get one byte offset in my buffer and the interrupt will fire too early. What is the best way to tackle this?2013-05-20 02:41 PM
Thank you Clive.
It is a Master-slave link in which the master sends a request and the slave sends a response.The syncronization on the master side is easier as it enables the RX dma when the TX has finished. Your solution is fine, but I think there are a chance of delays before a complete request could be assembled. Let's say some garbage data has arrived first. Part of a message will be pulled in with HT/TC, and the remaining part will start to be transferred by DMA to the receive buffer but it may be too few bytes to trigger a HT/TC. We then have to wait till the next request transmission. Or is it possible to use the timeout to examine the buffer to see if we have a complete message?2013-05-21 12:43 PM