Skip to main content
This topic has been closed for replies.
MM..1
MM..1Best answer
Super User
Feb 21, 2022 5:14 PM UTC

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
Super User
Feb 21, 2022 5:14 PM UTC

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
Feb 21, 2022 5:22 PM UTC

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 Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..