Skip to main content
David Ledger
Associate III
January 22, 2021
Question

How to use USART RTO timeout?

  • January 22, 2021
  • 5 replies
  • 1683 views

I have a STM32L4xx series microcontroller. My goal is to use RTO in USART to issue a timeout, from the time a read was attempted (not only from the last stop bit). This is needed as its possible for nothing to be received. How do I acheive this using RTO?


I've setup USART to interrupt on a timeout using:

CR2.RTOEN

CR1.RTOIE

 

And configured the timeout using:

RTOR.RTO

 

It works great, really nice feature. The RTO timeouts are always measured from the last stopbit/character received. However, I need to support a timeout even if zero characters were received. Does anybody know of a method to reset the RTO counter etc?

This topic has been closed for replies.

5 replies

KnarfB
Super User
January 22, 2021

I doubt that RTO can be used for that. A simplistic approach would be using HAL_UART_Receive with a small timeout value (SysTick). A more sophisticated approach could start a timer and use a timer interrupt when the time is over.

Piranha
Principal III
January 23, 2021

For "no reception" timeout typically a notification/event/semaphore wait function or other independent software/hardware timeouts are used.

David Ledger
Associate III
January 24, 2021

I thought that might be the case. Was looking for a dependable workaround to keep timeout functionality to the peripheral itself (just seemed like more modular design).

Appreciate the responses. Shame its not possible, honestly it seems like a trivial change to the functionality (force manual triggering of a stop bit). That said, I understand that'd be a respin of silicon and thats just not going to happen :(

Does anybody know if using internal pull-ups and bitbanging a USART rx to a stopbit would work?

waclawek.jan
Super User
January 24, 2021

>using internal pull-ups and bitbanging a USART rx to a stopbit

Surely the connected device pulls stronger than the pull-ups. And if not, you're risking corruption of genuinely incoming data.

> Shame its not possible, honestly it seems like a trivial change to the functionality

You can start an "Idea", maybe it'll stick, at least for future devices.

Meantime, just accept the status quo, as Piranha and KnarfB said.

JW

David Ledger
Associate III
February 15, 2021

thanks!