EE Primers · Communication interfaces · Board-Level Buses
UART, RS-232 and RS-485: asynchronous serial from the bit to the cable
A UART sends bytes with no clock wire. Transmitter and receiver agree on a bit rate in advance, and the receiver re-synchronises on the falling edge of every start bit, then samples each bit at its centre using a local clock. Everything that matters about UART follows from that: why the line idles high, why the bit order is LSB first, why a few percent of clock error breaks it, and why the physical layer (3.3 V logic, RS-232's inverted ±12 V, RS-485's differential pair) is a separate choice from the protocol. This page covers the frame, the receiver's sampling, the error budget, three reference circuits and the physical layers.
"UART" is the logic block; RS-232 (TIA-232-F) and RS-485 (TIA-485-A) are electrical standards that carry its frames off the board [1][2]. The same frame format also underlies LIN, DMX512, Modbus RTU and most bootloader consoles.
01 · At a glance
One frame format, three physical layers
Logic-level UART
RS-232
RS-485
Signalling
Single-ended, push-pull, 1.8–5 V CMOS
Single-ended, inverted, bipolar
Differential pair, half- or full-duplex
Logic 1 (mark, idle)
High (VDD)
−5 to −15 V driven; < −3 V at receiver
\(V_{\text{A}}-V_{\text{B}}\ge +200\ \text{mV}\) at receiver*
Logic 0 (space, start bit)
Low (0 V)
+5 to +15 V driven; > +3 V at receiver
\(V_{\text{A}}-V_{\text{B}}\le -200\ \text{mV}\)*
Topology
Point-to-point, on one board
Point-to-point
Multidrop, 32 unit loads (more with fractional-load parts)
Distance × rate
Centimetres
≈ 15 m (2500 pF) at 19.2 kbaud
≈ 10⁸ bit·m/s, up to ~1200 m
Ground
Shared
Shared, offsets of a few volts tolerated
Common mode −7 to +12 V tolerated
* Vendor convention, used on this page: A is the non-inverting output. The TIA-485 standard's own naming is the reverse, which is why "swap A and B" is a classic field fix (§07).
02 · Framing
The frame: start, data, parity, stop
Idle is high (mark). A line that is high when nothing is sent lets the receiver tell "idle" from "broken": a disconnected or shorted line reads as a continuous 0 (a break).
Start bit: one bit time low. Its falling edge is the only timing reference the receiver gets per character. Everything after it is timed from that edge with the receiver's own clock.
5–9 data bits, LSB first. 'O' = \(\text{4Fh}=0100\ 1111\) is sent 1, 1, 1, 1, 0, 0, 1, 0.
Optional parity bit: even parity makes the total number of 1s (data + parity) even; odd makes it odd. It catches single-bit errors only.
1, 1.5 or 2 stop bits, high. Guarantees a high-to-low edge for the next start bit, and gives the receiver time to finish the character.
The common 8N1 format (8 data, no parity, 1 stop) is 10 bit times per byte, so payload is 80 % of the baud rate: 115 200 baud carries 11 520 bytes/s. There is no addressing, checksum, framing beyond the character, or flow control in the UART itself; those come from the protocol on top (Modbus, LIN, SLIP, a bootloader's packet format).
03 · Worked example
Characters from transmitter to receiver, bit by bit
The waveform below is generated from the characters you type. It shows the same frame four ways: on the 3.3 V logic pin, on an RS-232 cable (inverted and bipolar), and on the two wires of an RS-485 pair. The receiver samples each bit at its centre, marked by the dashed lines. Default: "OK" at 115 200 baud, 8N1.
Frame builder
RS-232 is drawn inverted (mark = negative voltage). RS-485 A follows the logic level and B is its complement; the receiver looks only at VA − VB. Scroll sideways on narrow screens.
Reading 'O' (4Fh) in 8N1 step by step
Idle: TX high, RS-232 at about −6 V, RS-485 A above B.
Start bit: TX drops to 0 for one bit time (8.68 µs at 115 200 baud). The receiver detects this falling edge and starts timing.
Data, LSB first: \(\text{4Fh}=0100\ 1111\), sent as 1 1 1 1 0 0 1 0. On the scope the first four data bits merge with the stop-to-start pattern into one long high: count bit times, don't count edges.
Stop bit: high for one bit time. If the receiver samples 0 here it reports a framing error.
Next start bit follows immediately for 'K' \((\text{4Bh}=0100\ 1011\to 1\ 1\ 0\ 1\ 0\ 0\ 1\ 0)\).
04 · Edges
How the receiver finds the bits: which edge, which instant
There is no clock on the wire, so "which clock edge" becomes two questions: which line edge the receiver synchronises on, and which instant of its own clock it samples at.
Synchronisation edge: only the falling edge of the start bit (mark-to-space). Edges inside the character are ignored; the receiver free-runs on its own clock until the next start bit.
Sampling: a clock at 16× (sometimes 8× or 4×) the baud rate. The edge is seen on the first tick after it occurs, so detection has up to 1/16 bit of uncertainty. The receiver counts 8 ticks to the middle of the start bit and checks the line is still low (rejecting glitches as false starts), then samples every 16 ticks, at the centre of each bit.
Majority vote: many UARTs take three samples at ticks 7, 8 and 9 of each bit and use the majority, which rejects a short noise spike near the centre and sets a noise flag.
Transmitter side: the transmitter changes the line on its own baud clock (every 16 ticks of its oversampling clock). Bit edges are therefore placed with the transmitter's clock accuracy, and sampled with the receiver's.
Start-bit detection with 16× oversampling. Red: the edge falls between ticks and is seen up to 1/16 bit late. Amber bands: the three-sample majority window at each bit centre.
05 · Error budget
Baud-rate tolerance
Because the receiver only resynchronises once per character, clock error accumulates bit by bit. The last sample (the stop-bit centre in 8N1) is 9.5 bit times after the start edge and must still land inside the stop bit, i.e. within ±0.5 bit of where it should be.
$$\text{allowed total error}=(0.5-1/\text{OS})/(N_{\text{data}}+N_{\text{parity}}+1.5)\qquad 8\text{N}1,16\times :\,0.4375/9.5=4.6\ \%$$
That 4.6 % is the sum of both ends' errors, before edge distortion from the physical layer. The usual design target is ±2 % per side (±1.5 % for long frames). Crystals (±50 ppm) are irrelevant to this budget; internal RC oscillators (±1–3 % over temperature) consume most of it, and integer baud dividers often consume the rest. Drag the slider to see what happens past the limit.
Baud-mismatch explorer (one 8N1 character, 4Bh)
Dotted grey: ideal bit centres. Dashed: where this receiver actually samples. Numbers: what it reads (green correct, red wrong).
Worked dividerMCU UART clock 16 MHz, 115 200 baud, 16×: \(16\ \text{MHz}/(16\times 115\ 200)=8.68\to\) integer 9 → 111 111 baud, −3.55 %: fails. With 8× oversampling: 17 → 117 647 baud, +2.12 %: marginal. A fractional divider of 8 + 11/16 gives 115 108 baud, −0.08 %: passes. A 14.7456 MHz crystal divides exactly. Try these in the calculator.
06 · Circuits
Reference circuits
Logic-level UART between two chips
TX goes to RX, and a common ground is mandatory. The pull-up on each RX keeps an unconnected or unpowered transmitter from reading as a continuous break. The series resistors limit current if one side is unpowered (back-powering through the RX ESD diode) and damp ringing on longer traces.
RS-232 port
The transceiver's charge pumps generate about ±5.5 V from a 3.3 V supply and its drivers and receivers invert, so logic 1 leaves the connector as a negative voltage. On a DTE (a PC-style port) pin 3 transmits and pin 2 receives; a DCE swaps them, and connecting two DTEs needs a null-modem cable. TVS diodes rated for ±15 V sit at the connector.
RS-485 multidrop bus
One terminator at each end of the trunk, never at every node. Fail-safe bias (A pulled up, B pulled down, once on the bus) holds VAB above +200 mV when no driver is enabled, so idle reads as mark. Each node drives the bus only while its DE pin is high. Add a TVS rated for the −7/+12 V common-mode range (SM712 class) at each connector.
07 · Physical layers
RS-232 and RS-485 in detail
RS-232 (TIA-232-F)
Driver: ±5 V minimum into a 3–7 kΩ load, ±15 V maximum. Receiver: above +3 V is space (0), below −3 V is mark (1); −3 to +3 V is undefined.
Slew rate limited to 30 V/µs; transitions through the ±3 V region must be fast relative to the bit (no more than a few percent of the bit time).
Load: 2500 pF maximum, so roughly 15 m of cable at 19.2 kbaud; slower rates go further. Many modern transceivers run to 250 kbaud–1 Mbaud on short cables.
Ground-referenced: tolerates a few volts of offset, nothing like RS-485's common-mode range.
Hardware flow control (RTS/CTS) uses the same levels; DTR/DSR/DCD are mostly legacy.
RS-485 (TIA-485-A)
Driver: ≥ 1.5 V differential into 54 Ω (two terminators plus 32 unit loads). Receiver: ±200 mV threshold over −7 to +12 V common mode.
One unit load = 12 kΩ input; 32 per bus, or 128–256 with ¼–⅛ UL parts.
120 Ω twisted pair, terminated at both ends; daisy-chain, no stars; stubs short compared with the edge (a few cm at 10 Mbit/s, metres at 100 kbit/s).
Half-duplex: one pair, every node's driver gated by DE. Full-duplex (often called RS-422 style): two pairs.
Rate × \(\text{length}\approx 10^{8}\) bit·m/s: 100 kbit/s → ~1000 m, 10 Mbit/s → ~10 m. Cable loss and skew, not the standard, set the limit.
A and B namingTIA-485 defines A as the terminal that is negative for a mark; most transceiver vendors label the non-inverting output A, which is positive for a mark. Both are in the field. If a new device sees only framing errors on an otherwise healthy bus, check the A/B convention before anything else.
DE turnaroundIn half-duplex, firmware must keep DE asserted until the last stop bit has left the shift register: use the "transmission complete" flag, not "transmit buffer empty". Releasing DE early truncates the stop bit and the receiver reports a framing error on the last byte. Many MCUs can drive DE automatically from the UART (RS-485 mode, with programmable assertion and de-assertion times).
08 · Signal integrity
Rise time, fall time, distortion and skew
UART has no clock to skew against, but it has the equivalent: every edge is measured against the receiver's own time base, and the only edge that synchronises it is the start edge. Anything that moves edges relative to each other spends the same timing budget as baud error.
Pulse-width distortion (PWD). If a driver, isolator or receiver delays rising edges differently from falling edges \((t_{\text{PLH}}\ne t_{\text{PHL}})\), every high bit gets longer and every low bit shorter. The start bit is low, so its falling edge is the reference; a shortened start bit with a late centre sample is the first casualty. Keep total PWD below about 10 % of a bit time. Fast optocouplers (6N137 class) add tens of nanoseconds; transistor-output optocouplers (PC817 class) add microseconds and limit a link to tens of kbaud.
Slow edges and threshold differences. A slow edge crosses a 30 % threshold and a 70 % threshold at different times; with RC-filtered or long cables this becomes PWD. RS-232's 30 V/µs limit and the ±3 V undefined region make this explicit.
Differential skew in RS-485. A delay between A and B (unequal pair lengths, driver output skew) converts part of the differential signal into common mode and smears the zero crossing. Keep pair skew small relative to the bit time and use pairs, not two random conductors.
Reflections. On a terminated RS-485 bus, an unterminated end or a long stub rings, and ringing near the receiver threshold produces extra edges. An extra falling edge during idle looks like a start bit and produces a garbage character.
Slew-limited transceivers. RS-485 parts come in 250 kbit/s, 500 kbit/s and 20+ Mbit/s grades. The slow grades have controlled edges that tolerate stubs and unterminated short buses and emit far less EMI. Use the slowest grade that meets the bit rate.
Rule setBudget clock error, edge-detection quantisation (1/OS), and pulse-width distortion together against (0.5 bit) / (last-sample position). Put a pull-up on every logic RX. Use crystals above ~115 kbaud. On RS-485: twisted pair, two terminators, fail-safe bias once, short stubs, slowest transceiver that meets the rate.
09 · Around the frame
Flow control, break, auto-baud and LIN
Flow control
Hardware RTS/CTS: the receiver de-asserts its RTS (wired to the sender's CTS) when its FIFO fills; the sender finishes the current character and stops. Software XON/XOFF (11h/13h) in-band: only for text, and slow to react.
Break
The line held low longer than a full frame. Receivers report it as a break condition (all-zero character with a framing error). Used as a "reset/attention" signal by LIN, DMX512 and some bootloaders.
Auto-baud
The receiver times the first character's edges with a fast timer. Sending 55h ('U', alternating bits) or 'A' gives clean edges. Common in bootloaders and modems ("AT").
LIN (ISO 17987)
A UART frame on a single 12 V wire with slew-controlled edges, 1–20 kbit/s. Each frame starts with a break of at least 13 bit times, then sync byte 55h so slaves with ±14 % RC oscillators can measure the bit time, then a protected identifier. The master has a 1 kΩ pull-up, slaves 30 kΩ.
10 · When it breaks
Failure modes and debug signatures
Symptom
Likely cause
Check / fix
Garbage characters, consistent pattern
Wrong baud rate or format
Measure the narrowest pulse on the scope: that is one bit time. \(8.68\ \text{µs}=115\ 200\).
Mostly right, errors in the last bits or framing errors on some characters
Baud error near the limit (RC oscillator over temperature, integer divider)
Compute both ends' error; fractional divider, crystal, or lower rate.
Random characters while idle
Floating RX, noise on idle line, RS-485 bus without fail-safe bias
Pull-up on RX; bias or fail-safe transceivers on RS-485.
Last byte of each RS-485 packet corrupted
DE released before the stop bit finished
Use transmit-complete, or hardware DE control.
Bus works with two nodes, fails with more or at length
Missing or extra terminators, stubs, star wiring, too many unit loads
Two terminators at the physical ends; measure ≈ 60 Ω between A and B with power off.
Nothing received, only framing errors
A/B swapped, TX/RX not crossed, RS-232 levels into a logic pin
Swap A/B; check crossover; never wire RS-232 to an MCU pin.
Unpowered board partly powered up, or MCU damaged
Back-powering through RX ESD diodes; TTL taken off-board
Series resistors, Ioff-rated buffers, a transceiver at every connector.
Debug setupTrigger on the falling edge with a pulse-width condition (low pulse shorter than one character), set the decoder's baud and format, and measure one bit time with cursors. On RS-485, probe A and B with two probes and use the math channel A − B, or a differential probe.
11 · Design review
Checklist
Schematic
Baud error per side ≤ 2 % at temperature extremes, both ends
Pull-up on every logic RX; series R on lines leaving the board
Transceiver at every external connector; TVS sized for the standard
RS-485: terminators at the physical ends only, bias once, DE control strategy chosen
Isolators: pulse-width distortion inside the budget
Layout and cabling
RS-485 routed as a 100–120 Ω differential pair to the connector
Termination at the connector end
Twisted-pair cable with a ground/reference conductor, daisy-chained
Shield bonded at the enclosure entry
Bring-up
Measure the bit time on the scope at both ends
Check idle level and VAB with all drivers off
Send 55h continuously and check symmetry (PWD)
Run at temperature extremes
12 · Self-check
Questions
Which edge does a UART receiver synchronise on, and when does it sample?
Only the falling edge of the start bit. It then samples at bit centres, 8 ticks after the edge and every 16 ticks after that (16× oversampling), often with a three-sample majority around each centre.
In what order are the bits of 4Bh sent?
\(\text{4Bh}=0100\ 1011\). LSB first: 1, 1, 0, 1, 0, 0, 1, 0, framed by a 0 start bit and a 1 stop bit.
What is the maximum combined clock error for 8E1 with 16× oversampling?
The last sample is at \(8+1+1.5=10.5\ \text{bit}\) times. \((0.5-1/16)/10.5=4.17\ \%\), shared between both ends.
Why does an RS-485 bus need fail-safe bias?
With all drivers disabled and the bus terminated, VAB is about 0 V, inside the receivers' ±200 mV undefined band. Receivers then output noise, which the UART sees as start bits. Bias holds VAB above +200 mV so idle reads as mark.
A 12 V LIN slave uses an RC oscillator with ±10 % tolerance. How can it communicate?
LIN starts every frame with a break and a 55h sync byte; the slave measures the sync byte's edges and sets its baud rate to match before receiving the rest of the frame.
13 · Further reading
References
TIA-232-F, Interface Between Data Terminal Equipment and Data Circuit-Terminating Equipment Employing Serial Binary Data Interchange.
TIA-485-A, Electrical Characteristics of Generators and Receivers for Use in Balanced Digital Multipoint Systems.
Texas Instruments, The RS-485 Design Guide, application report SLLA272. Link
Analog Devices (Maxim), application note 2141, Determining Clock Accuracy Requirements for UART Communications.
ISO 17987, Road vehicles — Local Interconnect Network (LIN).