Skip to Content

Why Your UART Prints Garbage

1 December 2026 by
Why Your UART Prints Garbage
ARDRA LAB, Common Research Team

You wire TX to RX. You set both ends to 115200. You open the terminal and get ÿÿ ¤Ð instead of "Hello". The wiring is fine. The baud setting matches on paper. What does not match is how fast each chip really counts time. A UART has no clock wire, so each side counts its own. If the two counts drift apart by a few percent, the receiver reads the wrong bit, and text turns into garbage. This note shows why a few percent is enough, how to find the error in your own design, and how to fix it.

1. A UART has no clock. It guesses.

In SPI or I2C a clock wire tells the receiver when to read each bit. UART has only TX and RX. Both chips agree on a speed (the baud rate) beforehand, and each uses its own clock to count it out.

A common frame is called 8N1: one start bit, eight data bits, no parity, one stop bit. That is 10 bits per byte. The line sits high when idle. The falling edge of the start bit tells the receiver that a frame has begun.

Figure 1. The byte 0x41 ("A") sent as 8N1. Data goes out least significant bit first.

Most receivers run an internal clock at 16 times the baud rate. They find the start edge, wait 8 ticks to reach the middle of the start bit, then sample every 16 ticks. Mid-bit sampling gives the signal the most time to settle. This is the method described in Maxim/Analog Devices Tutorial 2141.

2. Why a few percent is enough to break it

The receiver syncs on the start edge of every frame, so errors do not pile up from one byte to the next. But inside one frame they grow. The last bit it must read is the stop bit, and its middle is 9.5 bit times after the start edge (1 start bit + 8 data bits + half a stop bit).

Figure 2. A clock error slides the sample point. At the stop bit it has slid the most.

Maxim's application note works the budget out at about ±3.3% of total clock mismatch on a clean, short link, and about ±2% on a poor link (a long or capacitive cable, slow edges). That is the total between the two chips, and it can be shared between them in any proportion.

So the question is never "is my baud set to 115200?" It is "how far off is each chip's real bit time, added together?"

3. Where the error comes from

Cause 1: baud divisor rounding

The UART makes its bit clock by dividing the system clock by a whole number. If the clock does not divide cleanly, the baud rate comes out a little off. With a 16x receiver clock, the divisor is f_clk / (16 x baud), rounded to the nearest whole number.

Figure 3. Baud error at 115200 with a 16x UART clock, by system clock. This is Ardra Lab's own calculation from the divisor formula above. Check your chip's datasheet for its exact scheme.

System clockDivisor (exact)UsedReal baudError
11.0592 MHz6.006115,2000%
16 MHz8.689111,111-3.55%
12 MHz6.517107,143-6.99%
8 MHz4.344125,000+8.51%

A 16 MHz clock looks like a safe, round number and still lands outside the 3.3% budget at 115200 before the other chip even adds its own error. Many MCUs offer a double-speed or fractional baud mode that cuts this error. 11.0592 MHz and 18.432 MHz crystals exist for exactly this reason: they divide into the standard baud rates with no remainder.

Cause 2: a loose clock source

A crystal is typically good to tens of ppm, far below 0.01%. A ceramic resonator is about ±0.5% initial, plus about ±0.5% over temperature and life, according to the same Maxim note. An on-chip RC oscillator can be worse, and its error changes with temperature and supply voltage. Check the datasheet figure for your part and your operating range. If your UART runs from an RC oscillator that is a percent or two off, you have already spent most of the budget.

Cause 3: errors from both ends add up

If your board has -3% and the PC-side USB-serial adapter has +1%, the link sees about 4% in total. Each side looked fine on its own.

4. Not the clock? Check these too

Garbage is not always timing. Rule these out first, they take a minute:

  • Frame format. 8N1 on one side and 7E1, or 2 stop bits, on the other gives garbage or framing errors even at the right speed.
  • Baud set on only one side. Check the terminal program, not just the firmware.
  • TX and RX not crossed. TX goes to RX and RX goes to TX.
  • No common ground. Both boards need a shared ground reference.
  • Voltage levels. 3.3 V logic into a 5 V part, or raw RS-232 levels (inverted, swinging both positive and negative) straight into an MCU pin, needs a level shifter or an RS-232 transceiver.
  • Noise and long wires. Slow, ringing edges shrink the usable sampling window, which also shrinks the clock error you can tolerate.
  • The first byte after wake-up. If the MCU sleeps and wakes on the UART edge, its clock may still be settling when the first frame arrives.

5. Find the error in five minutes

  1. Hook a scope or a logic analyser to the TX line and send one byte, for example 0x55. It alternates 0 and 1, so every bit is one clean pulse.
  2. Measure one bit width. At 115200 it should be 8.68 µs. At 9600 it should be 104 µs.
  3. Baud rate = 1 / bit width. Compare it with the baud you intended. The difference, in percent, is that side's error.
  4. Do the same for the other device. Add the two errors. Keep the sum inside about 2% to be safe.

A logic analyser's UART decoder helps too. Try the standard baud rates one by one. If one decodes cleanly, the other side is simply set to that speed.

6. How to fix it

  • Pick a system clock that divides into your baud rate cleanly (11.0592 MHz, 18.432 MHz), or use the MCU's fractional baud or double-speed mode.
  • Use a crystal for UART timing. Do not run a link you care about from an uncalibrated RC oscillator.
  • Calculate the real baud and error in your design review, for both ends. Write it next to the baud setting in the firmware.
  • Drop the baud rate. A lower rate on a bad link buys back margin because the bit is longer and the edges settle sooner.
  • Shorten the cable, add proper termination, or use a transceiver suited to the link (RS-485 for long runs).
  • Add a header, length and checksum or CRC to your messages, so a corrupted byte is detected instead of silently used.

FAQs

Why does my UART work at 9600 but fail at 115200?

Bit time shrinks with speed, so edges and clock rounding eat a larger share of the sampling window. The divisor rounding error is also usually bigger at higher baud rates, because the divisor is a smaller number.

How accurate must the baud rate be?

As a working rule, keep the total mismatch between the two ends within about ±2%, which is the poor-link figure in Maxim's note. On a clean, short link the theoretical limit is about ±3.3%, but you should not design to the limit.

Is garbage text always a baud mismatch?

No. A wrong frame format, swapped wires, a missing ground and wrong voltage levels give similar symptoms. Check them first, then measure the bit width.

Why does the error not build up over a long message?

The receiver re-syncs on the start bit of every frame. Only the error inside one frame (up to the stop bit) matters. Back-to-back bytes with no gap can still be tight, because there is no idle time to re-sync in.

Can I use the internal RC oscillator for UART?

Sometimes, if the part is factory trimmed, the temperature range is small, and the datasheet accuracy fits your budget with room to spare. For a product, a crystal is the safer choice.

Does a USB-to-serial adapter have this problem too?

It can. Adapters also derive baud from a clock and a divisor, so their real rate has some error. When you debug, include the adapter's error in the sum.

Sources

  1. Maxim Integrated / Analog Devices, "Determining Clock Accuracy Requirements for UART Communications", Tutorial 2141 (https://www.analog.com/media/en/technical-documentation/tech-articles/determining-clock-accuracy-requirements-for-uart-communications.pdf): 16x sampling, the 9.5 bit-time rule, the ±3.3% and ±2% error budgets, and resonator and crystal accuracy.
  2. Microchip, ATmega48A/PA/88A/PA/168A/PA/328/P datasheet, USART baud rate generator section (https://www.microchip.com/content/dam/mchp/documents/MCU08/ProductDocuments/DataSheets/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061B.pdf): how a UART derives its baud rate from the system clock and a divisor.

The divisor and error figures in Figure 3 and the table are Ardra Lab's own arithmetic from the 16x formula, rounded to the nearest whole divisor.

Written by ARDRA LAB, Common Research Team.

Share this post