A Little History
SPI, short for Serial Peripheral Interface, came out of Motorola in the 1980s, alongside their 68000-series microcontrollers. Unlike I²C, it was never formally standardized by any committee; it just became the de facto convention because it was simple to implement in hardware and fast enough to matter. That informal history is exactly why SPI has quirks like four numbered "modes" rather than one fixed behavior, because different manufacturers settled on slightly different conventions before anyone was enforcing one.
What It's Actually For
Fast, short-distance, chip-to-chip communication where wire count is cheap but speed matters, such as flash memory, SD cards, ADCs/DACs and small displays. Where I²C trades speed for wire count, SPI makes the opposite bet: more wires (four instead of two), but no addressing overhead and a clock rate that can run into the tens of MHz.
The clock and data lines are shared by every device on the bus, but there are no addresses, so each device also needs its own CS line: a dedicated select wire from the controller to that one device. Two or three devices is no problem. Every one you add costs the controller another GPIO pin, though, so a design with lots of SPI devices can run short of pins on select lines alone.
How It Works
The controller drives CS (chip select) LOW to begin talking to a specific peripheral. There's no start condition or address byte: CS itself is the framing. While CS is low, the controller toggles SCK, and on each clock edge one bit moves in each direction at once. The controller sends on MOSI while the peripheral sends on MISO at the same moment. The letters come from the original names, Master Out Slave In and Master In Slave Out. Newer datasheets say controller and peripheral instead (Controller Out, Peripheral In), but the pin names MOSI and MISO stuck around either way. Sending both ways at once is what makes SPI full-duplex. Unlike UART or I²C, both sides are always sending, whether or not either side has anything meaningful to say.
On the Sniffer Board
The SPI peripheral here is a real EEPROM. The controller sends a read command on MOSI (an opcode byte plus a two-byte address), and the EEPROM answers on MISO with the requested data. All four wires need to be captured to see the full exchange: the first few bytes on MOSI are the read command, and the interesting content is on MISO afterward.
| Pin | Connects to |
|---|---|
| CS | Logic analyzer channel D0 |
| MISO | Logic analyzer channel D1 |
| MOSI | Logic analyzer channel D2 |
| SCK | Logic analyzer channel D3 |
| Logic analyzer GND wire |
In PulseView: 4 MHz sample rate, 10 M samples (2.5 seconds). Add the SPI decoder and assign CS# = D0, MISO = D1, MOSI = D2, CLK = D3 (PulseView's name for the header's SCK pin).
The decoder's other settings (clock mode, chip-select polarity, bit order) are for you to check against your capture: zoom in on one transfer and compare it with the diagram above. If the bytes come out as garbage, those settings are the first place to look.