SPI Series · Part 1 of 5
What Is SPI (Serial Peripheral Interface)? A Beginner's Guide
If you've worked with microcontrollers, chances are you've run into SPI. It's one of the three most common serial protocols used to connect chips on a circuit board, alongside I2C and UART. This article covers what SPI is, why it exists, and where you'll find it in real projects.
🔎 The Short Definition
SPI stands for Serial Peripheral Interface. It's a synchronous serial communication protocol developed by Motorola in the 1980s, used for short-distance communication between a microcontroller and one or more peripheral devices — things like sensors, SD cards, displays, and shift registers.
⏱️ Why "Synchronous" Matters
SPI is called synchronous because it uses a dedicated clock line. Every bit of data is sent in step with a clock pulse generated by the master device. This is different from UART, which is asynchronous and relies on both sides agreeing on a baud rate ahead of time instead of sharing a clock signal.
🔌 The Four Wires
A standard SPI bus uses four signal lines:
| Signal | Role |
|---|---|
| SCLK | Serial Clock — generated by the master, paces the transfer |
| MOSI | Master Out, Slave In — data from master to slave |
| MISO | Master In, Slave Out — data from slave to master |
| CS / SS | Chip/Slave Select — master pulls this low to activate a device |
Newer documentation sometimes uses the terms COPI and CIPO instead of MOSI/MISO, but they refer to the same signals.
👑 Master-Slave Architecture
SPI is built around a single master controlling one or more slave devices. Unlike I2C, slaves don't have addresses. Instead, the master selects which device it wants to talk to by toggling that device's dedicated CS line. This means that if you have five SPI devices, you generally need five CS lines coming from your microcontroller — one per device.
⚡ Key Feature: SPI is full duplex — data moves in both directions (MOSI and MISO) at the same time, on every clock pulse. This makes it significantly faster than I2C for high-throughput jobs like SD cards, TFT displays, and ADCs.
🌍 Where You'll See SPI in the Real World
- ● SD/microSD card readers
- ● TFT and OLED displays
- ● Flash memory chips (e.g. W25Q series)
- ● Sensors (accelerometers, gyroscopes, temperature/pressure sensors)
- ● Shift registers for expanding GPIO pins
- ● Ethernet and radio modules (e.g. nRF24L01, ENC28J60)
Up Next in This Series
Part 2: SPI vs I2C vs UART — a full comparison to help you pick the right protocol for your project.
Comments
Post a Comment