AN4908 · Application noteGetting started with USART automatic baud rater detection for STM32 MCUs
Download .pdfOpen in the full document

Analysis of results

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 3. ABR error comparison (fCK = HSI clock, mode 2 for hardware detection)


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 4. ABR error comparison (fCK = 72 MHz, mode 2 for HW detection)


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.
Figure 5. Baud rate comparison (fCK = 72 MHz, desired baud rate = 9 Mbits/s, mode 2 for hardware detection)


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

Table 9. Document revision history
DateVersionChanges
15-Nov-20161Initial release.
01-Oct-20202

The following tables now scope STM32H7 series products:

  • Table 1: Applicable products

  • Table 2: USART hardware automatic baud rate detection on STM32 Series devices

  • Table 3: Hardware automatic baud rate detection on STM32 USART interfaces.

12-Jan-20233

Added STM32C0 and STM32U5 series:

  • Updated Table 1: Applicable products, Table 2: USART hardware automatic baud rate detection on STM32 Series devices and Table 3: Hardware automatic baud rate detection on STM32 USART interfaces
  • Modified STM32H7 series products in Table 3: Hardware automatic baud rate detection on STM32 USART interfaces
08-Mar-20244
The following tables now scope STM32G0, STM32H5, STM32L4, STM32L5, STM32U0, STM32WB STM32WBA, STM32WBL series products:
  • Table 1. Applicable products
  • Table 2. USART hardware automatic baud rate detection on STM32 series devices

  • Table 3. Hardware automatic baud rate detection on STM32 USART interfaces (mainstream)

  • Table 4. Hardware automatic baud rate detection on STM32 USART interfaces (high performance)

  • Table 5. Hardware automatic baud rate detection on STM32 USART interfaces (ultra-low power)

  • Table 6. Hardware automatic baud rate detection on STM32 USART interfaces (wireless)

12-Jun-20245The following tables now scope STM32G4 series, STM32WB0 series, and STM32H7Rx/7Sx products:
  • Table 1. Applicable products
  • Table 2. USART hardware automatic baud rate detection on STM32 series devices
  • Table 3. Hardware automatic baud rate detection on STM32 USART interfaces (mainstream)
  • Table 4. Hardware automatic baud rate detection on STM32 USART interfaces (high performance)
  • Table 5. Hardware automatic baud rate detection on STM32 USART interfaces (ultra-low power)
  • Table 6. Hardware automatic baud rate detection on STM32 USART interfaces (wireless)
06-Sep-20246Updated:
  • Document title
  • Table 3. Hardware automatic baud rate detection on STM32 USART interfaces (mainstream)

  • Table 5. Hardware automatic baud rate detection on STM32 USART interfaces (ultra-low power)

  • Table 6. Hardware automatic baud rate detection on STM32 USART interfaces (wireless)

16-Dec-20247The following tables now scope STM32N6 series:
  • Table 1. Applicable products
  • Table 2. USART hardware automatic baud rate detection on STM32 series devices
  • Table 4. Hardware automatic baud rate detection on STM32 USART interfaces (high performance)
13-Jan-20258The following tables now scope STM32U3 series:
  • Table 1. Applicable products
  • Table 2. USART hardware automatic baud rate detection on STM32 series devices
  • Table 5. Hardware automatic baud rate detection on STM32 USART interfaces (ultra-low power)

STM32U0 value in Table 5. Hardware automatic baud rate detection on STM32 USART interfaces (ultra-low power) updated.

21-Nov-20259The 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)