Module 67 min

SPI: Fast Four-Wire Serial

Simple, full-duplex, master-driven clock

Now to chip-to-chip serial protocols. SPI, the Serial Peripheral Interface, is the simplest and fastest of the three. It connects a master to one or more slave chips over a handful of wires.

The four wires

WireRole
SCLKSerial clock, driven by the master
MOSIMaster Out, Slave In (master to slave data)
MISOMaster In, Slave Out (slave to master data)
SS / CSSlave Select, one per slave, active low

How it works

The master pulls a slave SS low to select it, then generates the clock on SCLK. On each clock edge a bit shifts out on MOSI and a bit shifts in on MISO at the same time, so SPI is full duplex: data moves both directions simultaneously. There is no addressing scheme; the chip select line picks the slave.

Clock modes

SPI has four modes set by two choices: clock polarity (is the idle clock high or low) and clock phase (is data sampled on the first or second edge). Both ends must agree on the mode or the bits land wrong. This is the detail most people forget.

Strengths and limits

  • Fast and simple, no addressing overhead, full duplex.
  • But it needs a separate select line per slave, so many slaves means many pins.
  • No built-in acknowledge, so the master does not automatically know the slave received the data.
Pro tip

if asked SPI versus I2C: SPI is faster and full duplex but uses more wires (a select per slave) and has no acknowledgement; I2C uses only two wires and addresses many devices but is slower. That trade is the heart of most questions.