Serial Peripheral Interface (SPI)
SPI Mode
SPI Communication Example
Reference
Serial Peripheral Interface (SPI) is a high-speed, synchronous serial communication protocol used primarily for short-distance communication between microcontrollers and peripheral devices (like sensors, SD cards, or displays).
MOSI: The data line for sending information from Master to Slave.
MISO: The data line for sending information from Slave back to Master.
SCLK: The clock signal generated by the controller to synchronize data.
CS/SS: Used by Master to “wake up” a specific Slave before talking to it.
MOSI: The data line for sending information from Master to Slave.
MISO: The data line for sending information from Slave back to Master.
SCLK: The clock signal generated by the controller to synchronize data.
CS/SS: Used by Master to “wake up” a specific Slave before talking to it.

SPI Mode: The four SPI modes determine the clock edge on which data is sampled.

CPOL (Clock Polarity) – idle level of SCK
MOSI data is expected to be stable at those arrows.
SPI Mode 0 (CPOL = 0, CPHA = 0)
CPOL = 0→ idle lowCPOL = 1→ idle high
CPHA = 0→ first edgeCPHA = 1→ second edge
MOSI data is expected to be stable at those arrows.
SPI Mode 0 (CPOL = 0, CPHA = 0)
- Clock idles low
- Data is sampled on the rising edge
- Data changes on the falling edge
- Clock idles low
- Data is sampled on the falling edge
- Data changes on the rising edge
- Clock idles high
- Data is sampled on the falling edge
- Data changes on the rising edge
- Clock idles high
- Data is sampled on the rising edge
- Data changes on the falling edge
| SPI Mode | CPOL | CPHA | CLK Idle | Data Sampled On |
|---|---|---|---|---|
| Mode 0 | 0 | 0 | Low | Rising edge |
| Mode 1 | 0 | 1 | Low | Falling edge |
| Mode 2 | 1 | 0 | High | Falling edge |
| Mode 3 | 1 | 1 | High | Rising edge |
SPI Communication Example


Back to top of the page
