AnsweredAssumed Answered

USART with DMA receive Timeout

Question asked by net_id on Feb 6, 2012
Latest reply on Aug 5, 2015 by peacock.jack.003

Hi, I'm using an STM32F103 board running at 24Mhz. I have USART1 set at 115200 to send and receive transfers using DMA. This is working fine except when an incomplete packet is received. What I need to do is add a timeout capability similar to that suggested in Method 1 of AN3109.
Unlike method 1,  I was thinking it would function by setting a timer that would generate an update event interrupt (my timeout indication) at say a 3 character time interval (The time to receive 3 characters). If the update event interrupt is generated then a timeout has occurred. The timer is preferably started when the first character is received. Every time a character is received, the timer is reset. The timer is stopped when the whole packet has been received. Packets are at least 20 characters in length.

How do I connect an Input Capture to the RX line (PA10)? The manual really didn’t help me understand this (or I didn’t find the section that explains it).

I’m guessing I must have to use TIM1_CH3 as it is also listed as being on PA10.

Is that true or could I use a different timer and channel?

I’d really like to see sample code that sets up this configuration as I can’t find any.

Seems like something that would be useful to lots of users too.

 

Cheers                                  ...Laurie:{)

P.S. Having looked for this for days and then posting, within 30 minutes I find this:
http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/SW_DRIVER/an3109.zip

Just going through it now to see if it holds the asnwers.

...Laurie:{)

Answering my own questions:
You have to make a physical connection from the RX pin to a TIMx_CHn pin (where x and n are the timer and channel that will then monitor the comms).
I don't have a spare pin on the production board so I've decided that on the receipt of the first character I'll calculate the timer length to be 3 characters longer than the expected characters to be received (I know how many characters to expect). Start the timer.
If all the characters are received then stop the timer.
If not all characters are received, the timer will update and generate a timeout event.
Thanks         ...Laurie:{)

Outcomes