Hi,
I am receiving data packets (about 50 bytes) from a UART RX line using uDMA. I have enabled the FIFO mode on the UART. What would be the most efficient way to find out that the DMA data transfer has started?
Thanks
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I am receiving data packets (about 50 bytes) from a UART RX line using uDMA. I have enabled the FIFO mode on the UART. What would be the most efficient way to find out that the DMA data transfer has started?
Thanks
Sina,
That's an interesting question... I'll add this post more as a comment than as an attempt for a direct reply.
When we use DMA, the application no longer sees the "normal" peripheral interrupts (at least with Timers I'm sure). Rather, the interrupt is only flagged when the whole configured DMA transfer is finished.
In your case, that would be 50 bytes (or whatever fixed size you configured the DMA transfer)... Can you make a quick program to confirm that, if you configure your DMA for say 48 bytes, and only send a burst of 24 bytes, you will NOT get any interrupts? If you really don't, then the only way would be polling directly inside the DMA control array - you will have to figure out how that array is organized (there is documentation for that), and read the byte that contains the current number of transferred bytes (will not be efficient, apparently).
We spent a lot of time to come up with a solid receive/transmission UART library, and back then we did target for DMA - only to figure out it was not the most efficient solution for our need. You do have a 16 bytes FIFO available, and using a regular interrupt to be flagged at RX and RT works quite well.
- RX will interrupt when a "certain level" of the FIFO buffer is reached. If you configure it to 50%, it will trigger after 8 bytes are received, in which case you "already have 8 bytes to process, and at the same time, can still take as much as the amount of time required by the next 8 bytes" to read them. This 50% level is your choice, depending of how often you want to service the incoming bytes, and how fast you know you can service them.
- RT will interrupt when the above "RX level" has NOT been reached, but there has not been incoming signals in the UART for a bit longer that "one byte should arrive in continuous transmission" - in other words, probably the transmission burst has finished.
Hope this makes sense to you: don't try to process your incoming bytes inside the interrupt routine. Just quickly copy the received bytes to a buffer, and set a flag telling your program that "there's new stuff in the receive buffer". Your program must treat them afterwards, "outside the ISR, in main program flow".
Bruno
Hi Bruno,
May we note "great & caring" detail - your (above) post. Well done - clearly the "spirit" of this forum. (especially during "vendor-lite" dayze...)
Did I say we love your detail? (but for "- RT will interrupt when that level has NOT been reached") While "that level" (may) be understood - it "does" introduce an element of uncertainty. (brevity - said to be the "soul of wit" - is (infrequently) noted as, "soul of understanding" - mais oui?) Mercï...