Past exam question: Assignment 3, Q14
Open in the Padhaiko appQuestion
Compare UART, I2C, SPI protocol.
Solution
Side-by-Side Comparison of UART, I²C, and SPI:
| Feature | UART | I²C (Inter-Integrated Circuit) | SPI (Serial Peripheral Interface) |
|---|---|---|---|
| Full Name | Universal Asynchronous Receiver-Transmitter | Inter-Integrated Circuit (Two-Wire Interface) | Serial Peripheral Interface |
| Wires Required | (TX, RX) + GND | (SDA, SCL) + GND (plus pull-up resistors) | (MOSI, MISO, SCLK, SS/CS) + GND |
| Synchronization | Asynchronous (no shared clock; uses preset baud rate) | Synchronous (shared SCL clock line) | Synchronous (shared SCLK clock line) |
| Duplex Mode | Full-duplex (separate TX and RX) | Half-duplex (single shared SDA line) | Full-duplex (separate MOSI and MISO) |
| Topology / Addressing | Point-to-point only ( transmitter to receiver) | Multi-master, multi-slave using -bit / -bit software addresses | Single-master, multi-slave using hardware SS/CS lines |
| Typical Data Rate | Low to moderate ( – , up to a few Mbps) | Standard , Fast , High-speed | High speed () |
| Framing & Handshake | Start bit, data bits, optional parity, stop bits | Start/Stop conditions, 8-bit transfers with hardware ACK/NACK | Continuous shift-register bit stream; no ACK or start/stop overhead |
| Typical Applications | PC/USB-serial debugging, GPS/GSM/Bluetooth modules | On-board sensors (TC74, BMP280), EEPROMs, RTCs, OLEDs | SD cards, high-speed ADCs/DACs, TFT displays, flash memory |
Key Trade-Offs in Instrumentation Design:
- Choose UART for simple point-to-point links to external modules (GPS, RF modems, PC console) over moderate cable lengths without needing a clock wire.
- Choose I²C when connecting many low-to-medium-speed sensors on a single PCB using only two microcontroller pins (addressed by software ID).
- Choose SPI when maximum throughput and full-duplex streaming are required (high-speed ADCs, SD card data loggers, displays), at the cost of extra
CSpins.
Answer:
UART is an asynchronous, 2-wire (TX/RX), full-duplex, point-to-point protocol suited for moderate-speed external links; I²C is a synchronous, 2-wire (SDA/SCL), half-duplex, multi-master/multi-slave bus using 7/10-bit addressing and ACK bits (); and SPI is a synchronous, 4-wire (MOSI/MISO/SCLK/SS), full-duplex, highest-speed () single-master protocol using hardware chip-select lines.