7.2 Baud Rate Tolerance
Unlike most serial protocols, UART does not use a dedicated clock line to synchronize data between the transmitter and receiver. For UART to capture data, configure both the transmitter and receiver baud rate to run at the same data rate. Even if configured at the same data rate, the clock sources for the UART receiver or transmitter will have an error that impacts the actual baud rate. If the total error between the transmitter and receiver is too high, the serial data may randomly be corrupted. Measure the UART baud rate with an oscilloscope or logic analyzer.
There are a few ways to resolve or prevent this issue:
- Use tight tolerance oscillators/crystals to ensure clock accuracy (on both)
- Auto-Baud Detection in some UART
peripherals can be used to automatically set the baud rate on initialization by
having the transmitter send a specific character
- This would correct for clock error in the MCU
- Reduce the baud rate of the UART
- As UART transmits faster, the timing margin decreases