Topics / Communication Protocols / Q1
Compare UART, SPI and I2C.
Short answer: UART is asynchronous, point-to-point, two signal wires (TX, RX), no clock: both sides agree on a baud rate. SPI is synchronous, full duplex, a controller drives the clock, four wires plus one chip-select per device, very fast and simple. I2C is synchronous, half duplex, two open-drain wires shared by many devices with addresses and per-byte acknowledgements, slower but uses very few pins.
| UART | SPI | I2C | |
|---|---|---|---|
| Wires | TX, RX (+ GND) | SCLK, MOSI, MISO, CS (one CS per device) | SDA, SCL (+ pull-ups) |
| Clock | none (asynchronous, agreed baud) | controller drives SCLK | controller drives SCL (targets can stretch it) |
| Duplex | full | full | half |
| Topology | point to point | one controller, many peripherals | multi-controller, multi-target bus |
| Addressing | none | chip select line | 7-bit (or 10-bit) address in the message |
| Speed | typically ≤ 1–3 Mbps (some to 10+) | tens of MHz (50–100+ MHz with QSPI) | 100 kHz, 400 kHz, 1 MHz, 3.4 MHz |
| Acknowledgement | none | none | ACK/NACK per byte |
| Error detection | optional parity, framing | none (protocols add CRC) | ACK only (SMBus adds PEC) |
| Distance | board level; long with RS-232/RS-485 | board level (cm) | board level (bus capacitance ≤ 400 pF) |
| Typical devices | debug console, GPS, modems, BLE/Wi-Fi modules | flash, displays, ADCs, SD cards, IMUs | sensors, EEPROMs, PMICs, touch controllers, RTCs |
One-line pros and cons
- UART: simplest and universal, but needs matching baud rates and connects only two devices.
- SPI: fastest and simplest hardware, no addressing overhead, but many pins with multiple devices and no built-in acknowledgement.
- I2C: two pins for many devices with built-in addressing and ACK, but slow, sensitive to bus capacitance, and a misbehaving device can hang the whole bus.