Skip to main content
This topic has been closed for replies.
Best answer by MM..1

Your code have primary trouble handle how many timer reloads occurs over first to last for example device send FF FF FE on USART ...

Too __HAL_TIM_SET_COUNTER(htim, 0); why

Read STM32 USART automatic baud rate detection AN4908

2 replies

MM..1
MM..1Best answer
Chief III
February 21, 2022

Your code have primary trouble handle how many timer reloads occurs over first to last for example device send FF FF FE on USART ...

Too __HAL_TIM_SET_COUNTER(htim, 0); why

Read STM32 USART automatic baud rate detection AN4908

Tesla DeLorean
Guru
February 21, 2022

You can change the UART->BRR by clearing the UE (Uart Enable) bit first in UART-CR1, and then re-enable.

With some awareness of the uint16_t number space, the delta time is actually less complicated to compute than you're making it.

You'd perhaps use PWM Input Capture and filter/check based on normative baud rate expectations. Have patterns or pairs in your a stream you can recognize/verify.

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