OTD ACADEMY
Sign in / Sign up
Library

LIBRARYSPI, the four-wire bus.

SPI is the fast clocked serial bus: a controller drives the clock, picks a peripheral with chip-select, and data flows both ways on MOSI and MISO.

SPI is the fast bus on a board. A controller drives a clock line, picks one peripheral with a chip-select, and data moves both ways at once on two data lines. When an ADC or a display has to shift a lot of data quickly, it is usually on SPI.

The four lines

SPI uses four signals. SCK is the clock the controller drives. MOSI carries data from controller to peripheral, MISO carries it back the other way, so the bus is full-duplex. CS, the chip-select, picks which peripheral is active. Every peripheral shares SCK, MOSI, and MISO, and gets its own CS.

One chip-select per peripheral

The controller talks to exactly one peripheral at a time by pulling that peripheral's CS low; the rest ignore the bus while their CS stays high. Add a second peripheral and you add one more CS pin. That is the main cost of SPI: the bus is fast, and each peripheral you add costs another pin.

Deep dive· SPI modes: CPOL and CPHA

SPI has four modes set by two choices: the clock's idle level (CPOL) and which clock edge the data is sampled on (CPHA). Both ends must use the same mode, or every byte reads wrong, and the peripheral's datasheet states which one it needs. Mode 0, an idle-low clock sampled on the rising edge, is the common default. A wrong mode is a frequent first-bringup bug: the wiring checks out, the clock runs, and the data is still nonsense, because the two sides disagree on which edge carries the bit.

One SPI controller wired to two peripherals: shared SCK, MOSI, and MISO lines, with a separate chip-select to each peripheral.
One controller, two peripherals: shared SCK/MOSI/MISO, and a chip-select for each.

On a One Thousand Drones precision-ADC board the converter rides SPI so the microcontroller can pull sample after sample fast enough to keep up with the signal, with a single chip-select line picking it out.

Checkpoint

Quick check

What selects which SPI peripheral is active?
On SPI, which line carries the clock?
Add another SPI peripheral to the bus and what does it cost you?
0 / 3 correct

One Thousand Drones engineering team · verified 2026-07