cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to ''interrupt'' a receiving DMA ?

root
Associate II
Posted on September 26, 2012 at 22:55

Hello,

I was wondering (didn't checked yet in the datasheets, but perhaps somebody already has the answer) if it was possible, for example, to start a dma transfer from a receiving communication hardware (let's say UART), and after some time, stop it and get the number of bytes received and the data (I guess the data can be found in the destination memory, but where can I find the number of bytes transfered by the DMA ?).

Thomas.

#usart-dma
5 REPLIES 5
Posted on September 26, 2012 at 23:13

I'd presume you'd read one of the pointers, or NDTR, although you'd need to keep track of the initial values to infer the amount actually processed, vs not.

See DMA_GetCurrDataCounter()

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jpeacock2399
Associate II
Posted on September 27, 2012 at 01:02

Use a timer capture input tied to the receive data line and set up the capture to reset the timer.  As long as a bit stream arrives the timer is reset, meaning data is still in progress.  When the bit stream stops, the timer expires and generates an interrupt.  This signals the RX dma is complete.  Terminate the RX DMA and use the remaining data counter NDTR register to determine how much data you received.

  Jack Peacock

root
Associate II
Posted on September 27, 2012 at 12:02

Hello,

That is a VERY elegant way to handle data frames !

Did you already implemented this kind of DMA + TIM + USART interaction ? I'm not a DMA expert at all ...

Thomas.
root
Associate II
Posted on October 03, 2012 at 16:11

Hello,

I thought about what you said tons of time ... but am I right you need to physically connect the tim input with the UART receiver ?

If I'm right then unfortunately it's not applicable anymore (already in production) for my current project, but I'll use it on coming projects.

Thomas.

Posted on October 03, 2012 at 17:40

but am I right you need to physically connect the tim input with the UART receiver ?

Many of the USARTx_RX pins have a secondary function of a TIMx_CHx input, at least on the F1 series this could route internally. For the F2 and F4, the AF routing mux might get in the way.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..