cancel
Showing results for 
Search instead for 
Did you mean: 

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?

David Ledger
Associate III

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?

5 REPLIES 5
KnarfB
Principal III

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
Chief II

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

David Ledger
Associate III

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?

>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

thanks!