Q&A-1How do UART, I2C, and SPI compare across wire count, throughput, clock synchronization, bus topology, and hardware complexity?
Answer
Pick by clocking model first: it decides everything else. UART has no clock line, so both ends must agree on a baud rate and re-synchronise on every start bit; that makes it point-to-point, cheap, and drift-limited. I2C and SPI both carry a clock, so they are synchronous and can share a bus: I2C spends two wires plus in-band addressing to get multi-drop, SPI spends wires to get speed and near-zero protocol logic. On a board the deciding axis is pin budget against required payload rate.
| Axis | UART | I2C (UM10204) | SPI (no formal standard; typical MCU block) |
|---|---|---|---|
| Wires | 2 (TX, RX); 4 with RTS/CTS | 2 (SDA, SCL), open-drain, plus pull-ups | 4 for one slave (SCLK, MOSI, MISO, CS); 3 + N for N slaves with individual CS; 3 + 1 daisy-chained |
| Clock | Asynchronous. Shared baud rate, re-synced on each start bit, 16× oversampling | Synchronous, SCL driven by master; slave may stretch SCL low | Synchronous, SCLK driven by master; continuous or gated per transfer |
| Topology | Point-to-point full-duplex (RS-485 extends it to a half-duplex multidrop) | Multi-master, multi-slave, 7- or 10-bit addressing, arbitration on collision | Single master, multi-slave via CS; no addressing, no arbitration |
| Throughput | 115.2 kbaud typical; 1–3 Mbaud common on MCUs, ~12 Mbaud on dedicated bridges | 100 k / 400 k / 1 M / 3.4 Mbit/s (Standard / Fast / Fast+ / High Speed) | 10–50 MHz common; some MCUs clock past 100 MHz |
| Complexity | No clock line, but the baud divisor must land inside tolerance | START/STOP, ACK/NACK, addressing, arbitration, clock stretching | Shift register in silicon; cost is pins and the absence of any ACK |
What the wire actually carries. Protocol overhead is not a rounding error at these rates:
| Link | Clocks or bit-times per byte | Effective payload |
|---|---|---|
| UART 115.2 kbaud, 8N1 | 10 (1 start + 8 data + 1 stop) | 11.5 kB/s |
| UART 3 Mbaud, 8N1 | 10 | 300 kB/s |
| I2C Fast 400 kHz | 9 (8 data + ACK) | 44.4 kB/s |
| I2C High Speed 3.4 MHz | 9, plus the HS master-code byte | ~370 kB/s |
| SPI 50 MHz | 8 | 6.25 MB/s, each direction simultaneously |
So SPI at 50 MHz is roughly 140× I2C Fast mode, and the gap is structural: I2C pays an ACK clock per byte and an open-drain edge that cannot be driven fast.
Two numbers that decide real designs.
Baud divisor. A 16 MHz system clock divided by 16 × 115200 gives 8.68, so the nearest integer divisor is 9 and the actual rate is 16e6/(16×9) = 111.1 kbaud: 3.6% low. The 8N1 frame is 10 bit-times and the stop bit is sampled at 9.5 bit-times, so the total error budget is 0.5/9.5 ≈ 5.3%, i.e. ±2.6% per side. 3.6% on one side blows it. Switching to 8× oversampling gives 16e6/(8×115200) = 17.36 → divisor 17 → 117.6 kbaud, +2.1%, which fits. This is why 14.7456 MHz exists: 14.7456e6/(16×115200) = 8 exactly.
I2C pull-ups. Fast mode needs t_r ≤ 300 ns, and t_r = 0.8473 × Rp × Cb. The sink must also reach VOL = 0.4 V at IOL = 3 mA, so Rp(min) = (3.3 − 0.4)/3 mA = 967 Ω. At Cb = 400 pF, Rp(max) = 300 ns/(0.8473 × 400 pF) = 885 Ω: below Rp(min), so no valid resistor exists. The two limits cross at Cb ≈ 366 pF. At 3.3 V, keep a Fast-mode bus under ~350 pF, not the 400 pF the spec table lists.
Failure modes and how you see them.
- I2C bus lockup. A slave reset mid-byte holds SDA low; the master's own reset does not clear it. Detect: SDA reads low while SCL is idle high. Recover by clocking SCL nine times manually, then issuing STOP.
- I2C arbitration loss / NACK. The ARLO and NACK status bits fire; a NACK on address means the device is absent or its address strapping is wrong.
- SPI silent failure. There is no ACK. A dead or unpowered slave just returns 0x00 or 0xFF on MISO. Detect by reading a known device ID register (JEDEC ID on flash) at init, and by checking CPOL/CPHA against a known pattern: a mode mismatch shifts every byte by one bit and looks like plausible data.
- UART framing and overrun. The framing-error flag means the stop bit was not high (baud mismatch or noise); the overrun flag means the RX buffer was not read in time. Both are status-register bits, not exceptions.
When not to use each. SPI has no error detection, no flow control and no addressing: do not run it over a metre of cable; use RS-485 or CAN. I2C is not a bulk-data bus: 9 clocks per byte and open-drain edges cap it well below SPI. UART without a transceiver is point-to-point only, and without RTS/CTS it will overrun under sustained load.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.