School/○ Innovator/Elective · ECE-310
UART: one wire, ten bits, one byte
There is no clock wire between your laptop and a GPS module, yet not a single bit gets lost. How does the receiver know when each bit starts?
About 35 min · 3 goals · Checked by automated tests
1.Why should I care?
Almost every microcontroller has a UART, and almost every debugging session starts with one: printing sensor values, talking to a GPS or Bluetooth module, flashing firmware. When the text comes out as garbage, the fix is nearly always in the frame: the wrong baud rate, the wrong parity, or a missing ground wire. Knowing the ten bits of a frame turns that garbage into a diagnosis.
- ◇ Draw a UART frame: idle high, start bit, 8 data bits least significant first, optional parity, stop bit.
- ◇ Convert a baud rate into bit time, frame time and maximum bytes per second.
- ◇ Decode a captured frame into a byte and its ASCII character, and check its parity.
2.Predict
A UART sends at 9600 baud (9600 bits per second). About how many bytes of text per second can it carry?
Guess first. Being wrong here is how the surprise works.
3.Discover
Pick the letter A (65) and look at the waveform: find the start bit and read the data bits from left to right. Then flip one data bit with parity off, then with even parity on. Which setting notices the damage?
Loading the interactive…
Can't use the interactive? Read a description instead
The UART diagram draws one frame as a square wave. For the letter A (65 = 0x41) with even parity the line reads, in time order: start 0, data 1 0 0 0 0 0 1 0, parity 0, stop 1. Choosing a byte updates the bits; choosing a data bit to flip inverts it and the readout reports the wrongly decoded byte and whether the parity check fails (it fails for any single flip when parity is on; with no parity the error is not noticed).
4.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1
What level does a UART transmit line sit at when nothing is being sent?
Practice 2
After the start bit, a UART frame carries the data bits 0 0 1 0 1 1 0 0 (first to last, least significant bit first). What byte value is that, in decimal?
5.Watch
→ Watch for the start bit that wakes the receiver up and the order the data bits arrive in.
A short, clear explanation of UART framing and baud rate.
6 min 11 s · captions on YouTube · source
Nothing loads from YouTube until you press play.
The video is optional: everything you need is also in the lesson text and the interactive.
6.Understand
Asynchronous means no shared clock
A UART line rests high (idle). To send a byte, the transmitter pulls it low for one bit time: the start bit. The receiver sees that falling edge, waits half a bit, then samples once per bit time. Both sides must agree on the baud rate in advance; each keeps its own clock, so they only have to stay in step for one short frame before the next start bit lines them up again.
The frame, bit by bit
After the start bit come 8 data bits, least significant bit first, then an optional parity bit, then a stop bit (high) that returns the line to idle. The common format 8N1 means 8 data bits, no parity, 1 stop bit: 10 bits on the wire per byte. 8E1 adds an even-parity bit (11 bits). The letter A is 0x41 = 01000001, so the data bits go out as 1 0 0 0 0 0 1 0.
Parity: a one-bit alarm
With even parity the transmitter picks the parity bit so the total number of 1s in data + parity is even. 0x41 has two 1s, so its even-parity bit is 0. If noise flips any single bit, the count becomes odd and the receiver flags the frame. Two flipped bits cancel out and slip through, so parity detects errors but cannot correct them; real protocols add checksums on top.
When the text turns to garbage
A baud-rate mismatch makes the receiver sample in the wrong places, so bytes decode as nonsense or framing errors (no high stop bit where one was expected). Other usual suspects: transmit wired to transmit instead of crossing TX→RX, no shared ground, or a 5 V device talking to a 3.3 V input. UART voltage levels are a separate choice from the frame format.
Explain it another way
It is like a starter's pistol at a race. Everyone is quiet (idle high), the pistol fires (start bit), and then the receiver counts: one, two, three… reading one bit on each beat. It only has to count accurately for ten beats before the next pistol shot resets everything.
A UART is a shift register plus a baud-rate generator. The receiver oversamples (often 16× the baud rate), detects the falling start edge, and samples each bit near its centre. Clock error between the two ends must stay under roughly half a bit across the whole frame, which for 10 bits means a few per cent at most.
Bit time T = 1/baud. Frame time = n·T for an n-bit frame (n = 10 for 8N1, 11 for 8E1 or 8N2). Maximum throughput = baud/n bytes per second. At 115200 baud 8N1: T ≈ 8.68 µs, frame ≈ 86.8 µs, throughput = 11 520 bytes/s.
A robot logging 20-byte sensor packets 100 times a second needs 2000 bytes/s. At 9600 baud 8N1 (960 bytes/s) the log falls behind; at 115200 baud (11 520 bytes/s) it uses about 17% of the link, leaving room for debug messages.
Derivation: From baud rate to bytes per second
One bit lasts T = 1/baud seconds. At 9600 baud, T = 1/9600 s ≈ 104.2 µs.
One 8N1 frame is 1 start + 8 data + 1 stop = 10 bits, so it lasts 10·T ≈ 1.042 ms.
Back to back with no idle gaps, frames per second = 1/(10·T) = baud/10 = 960.
Each frame carries one data byte, so the maximum data rate is 960 bytes/s. In general: bytes/s = baud ÷ (bits per frame).
Worked example 1
A logic analyser shows, after the start bit, the data bits 0 0 1 0 1 1 0 0 (first to last). What byte is it?
The first bit is bit 0. Reverse to read MSB first: 00110100 = 32 + 16 + 4 = 52 = 0x34, the ASCII character '4'.
Worked example 2
How long does one 8E1 frame take at 115200 baud?
11 bits × (1/115200 s) = 11 × 8.68 µs ≈ 95.5 µs.
Common mix-ups
- Baud rate ÷ 8 gives bytes per second.
✓ Divide by the frame length: 10 bits for 8N1, so 9600 baud carries 960 bytes/s, not 1200. - Bytes are sent most significant bit first, just as we write them.
✓ UART sends the least significant bit first; I²C and most SPI devices send the most significant bit first. - Parity can fix a corrupted byte.
✓ Parity only detects an odd number of flipped bits. It cannot tell which bit flipped, and two flips go unnoticed.
7.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 3
A UART uses even parity. What parity bit goes with the data byte 0x07 (00000111)?
Practice 4
At 9600 baud with 8N1 framing and no gaps, what is the maximum data rate, in bytes per second?
Practice 5
Your microcontroller prints readable text in one terminal but random symbols in another. What is the most likely difference?
Practice 6 · a fresh version every time
A UART runs at 115200 baud with 1 start bit, 8 data bits, an even parity bit, 1 stop bit per frame. How long does one frame take, in microseconds? (1 decimal place)
Practice 7 · a fresh version every time
A logic analyser captures one 8N1 UART frame. After the start bit, the 8 data bits arrive in this order (first to last): 1 0 0 0 1 0 1 0. UART sends the least significant bit first. What byte value was sent, in decimal?
Practice 8 · a fresh version every time
A sensor streams bytes back to back over a UART at 19200 baud, using 1 start bit, 8 data bits, an even parity bit, 1 stop bit. At most how many data bytes per second can it send? (nearest whole byte)
8.Apply it
Design the UART link for a weather station that sends a 32-byte packet every 0.1 s. Choose the slowest standard baud rate (9600, 19200, 38400, 57600, 115200) that uses under half the link with 8N1, and show the numbers. Then add even parity: does your choice still work?
9.Reflect
Concepts: Serial communication: UART, I2C and SPI