2026-04-26
You've built flip-flops, counters, shift registers, and FIFOs. Now the question: how does one chip send data to another? The answer is serial bus protocols — and three of them dominate embedded systems: UART, SPI, and I2C.
UART (Universal Asynchronous Receiver-Transmitter) is the simplest. Two wires: TX and RX. No shared clock — both sides agree on a baud rate beforehand. The transmitter sends a start bit (low), 8 data bits (LSB first), and a stop bit (high). The receiver samples the line at 16× the baud rate, detects the falling edge of the start bit, then samples each data bit at the midpoint. This is literally a shift register with a baud rate generator (a counter that divides your system clock). At 115200 baud, each bit lasts 8.68 µs. The receiver's clock can drift up to ±5% before it samples the wrong bit — that's your design margin.
SPI (Serial Peripheral Interface) adds a clock wire, making it synchronous. Four signals: SCLK (clock), MOSI (master-out-slave-in), MISO (master-in-slave-out), and CS (chip select, active low). The master drives SCLK and shifts data out on MOSI while simultaneously shifting data in on MISO — it's two shift registers forming a circular buffer. SPI is fast (10–100 MHz typical) because there's no protocol overhead, no addressing, no ACKs. The tradeoff: every slave needs its own CS line. With 8 sensors, that's 8 extra pins.
I2C (Inter-Integrated Circuit) solves the pin problem with just two wires: SDA (data) and SCL (clock). Both are open-drain with pull-up resistors — any device can pull the line low, but nobody drives it high. This enables multi-master arbitration: if two masters transmit simultaneously, the one that sends a 1 while the other sends a 0 loses (it sees the line is low when it expected high) and backs off. Addressing is built in — every transaction starts with a 7-bit device address. Typical speed: 100 kHz (standard) or 400 kHz (fast mode). The pull-up resistors and bus capacitance form an RC circuit that limits speed. Rule of thumb: keep total bus capacitance under 400 pF, which means trace length under ~50 cm at 400 kHz.
Real-world example: A temperature sensor on a PCB. You'd pick I2C for a single sensor (minimal wiring, address-based), SPI for a high-speed ADC streaming samples at MHz rates, and UART for a GPS module that sends NMEA sentences to your microcontroller. The hardware for all three is built from blocks you already know: shift registers do the serialization, counters generate timing, and state machines manage the protocol framing.
