Error calculation
Figure 2 Error calculation for ABR at fCK = 72 MHz, 115200 bits/s desired baud rate shows that ABR modes 2 and 3 are more precise than modes 0 and 1. They provide a lower baud-rate error figure.
Nevertheless, all modes exhibit good results, as the error between the desired and actual baud rates is less than 1%.

Comparison of software and hardware approaches
Figure 3 ABR error comparison (fCK = HSI clock, mode 2 for hardware detection) shows that in general, when the USART is clocked by the system clock at 72 MHz (with the HSE as the PLL clock source), the results are better than when the USART clock source is used as the HSI clock. This is due to the relative inaccuracy of the HSI.

Figure 4 ABR error comparison (fCK = 72 MHz, mode 2 for HW detection) shows that in most cases the hardware approach provides better results than the software approach. The software approach nevertheless provides good results that are in some cases comparable to those obtained using the hardware approach.

Figure 5 Baud rate comparison (fCK = 72 MHz, desired baud rate = 9 Mbits/s, mode 2 for hardware detection) shows that:
- With the hardware approach, the maximum baud rate reach 9 Mbits/s with 0% error.
- With the software approach, the error at maximum baud rate is about 30%, which is explained by the CPU cycles spent executing the interrupt handler.

Conclusion
This application note describes the hardware automatic baud rate detection feature embedded in some STM32 devices. It also provides a technique for implementing this feature in software, as a solution for STM32 devices not implementing this feature in hardware.
Although the automatic baud rate detection is applied at the beginning of the examples, it could be extended and used whenever the transmitter and receiver devices detect communication errors. This allows a robust application where the host varies its baud rate between communications.
Revision history
| Date | Version | Changes |
|---|---|---|
| 15-Nov-2016 | 1 | Initial release. |
| 01-Oct-2020 | 2 |
The following tables now scope STM32H7 series products:
|
| 12-Jan-2023 | 3 |
Added STM32C0 and STM32U5 series:
|
| 08-Mar-2024 | 4 |
The following tables now scope STM32G0, STM32H5, STM32L4, STM32L5, STM32U0, STM32WB STM32WBA, STM32WBL series products:
|
| 12-Jun-2024 | 5 | The following tables now scope STM32G4 series, STM32WB0 series, and STM32H7Rx/7Sx products:
|
| 06-Sep-2024 | 6 | Updated:
|
| 16-Dec-2024 | 7 | The following tables now scope STM32N6 series:
|
| 13-Jan-2025 | 8 | The following tables now scope STM32U3 series:
STM32U0 value in Table 5. Hardware automatic baud rate detection on STM32 USART interfaces (ultra-low power) updated. |
| 21-Nov-2025 | 9 | The following tables now scope STM32C5 series:
The following table now scope STM32C5 series: Table 4 Hardware automatic baud rate detection on STM32 USART interfaces (high performance) |