SPI Protocol

SPI (Serial Peripheral Interface) is a synchronous, full-duplex serial link between a controller and one or more targets on the same board: a clock (SCLK), a data line in each direction (COPI and CIPO, formerly MOSI and MISO) and one chip select per target. To watch a bus, use a protocol analyser such as the Beagle I2C/SPI, which monitors SPI to 24 MHz without driving it, or a logic analyser with an SPI decoder. To drive SPI devices from a PC, use a host adapter such as the Aardvark or the faster Cheetah.

4 wiresSCLK, COPI, CIPO, plus one CS per target
Full duplexOne bit each way on every clock
Push-pullNo pull-ups, no addresses, no acknowledge
4 modesClock polarity and phase (CPOL, CPHA)
Dual and Quad2 or 4 data lines for serial flash
No formal standardEach device datasheet defines its timing

How the SPI Bus Is Wired

The controller drives the clock and both outputs are actively driven high and low, so there are no pull-up resistors to size and no rise-time limit from the bus as there is on I2C. Instead of addresses, each target has its own chip select (CS, also called SS or CE), normally active low. The controller pulls one CS low, clocks the transfer, then releases it. A target whose CS is high must leave CIPO in high impedance so it does not fight the selected device.

SPI wiring: one controller, two targets, shared clock and data, one chip select per targetA controller drives SCLK and COPI (MOSI) to both targets and reads CIPO (MISO) back from them. Each target has its own chip select line, CS0 and CS1, driven low by the controller to select it. A protocol analyser taps the same lines and only listens.ControllerMCU or SoCSCLKCOPI (MOSI)CIPO (MISO)CS0CS1Flashtarget 0ADCtarget 1Protocol analyserlistens, never drives
One controller and two targets. SCLK, COPI and CIPO are shared; each target has its own chip select. A protocol analyser taps the same lines and only listens.

The older names MOSI (master out, slave in) and MISO (master in, slave out) still appear on most datasheets and tools. Newer documents use SDO and SDI as seen from each device, or controller and peripheral names such as COPI and CIPO or PICO and POCI (the OSHWA recommendation). They are the same signals.

How an SPI Transfer Works

SPI mode 0 transfer of one byte in each directionChip select falls to start the transfer. SCLK idles low and pulses eight times. The controller shifts out 0x9F on COPI while the target shifts out 0xC2 on CIPO at the same time. Both sides sample on each rising clock edge and change data on each falling edge. Chip select rises to end the transfer.CSSCLKCOPICIPOb7b6b5b4b3b2b1b0Sampled on each rising SCLK edge (dashed lines)
Mode 0: the controller shifts out 0x9F while the target shifts out 0xC2 in the same eight clocks. Data changes on the falling edge and is sampled on the rising edge. On a real flash, the reply to the 9Fh ID command comes in the clocks that follow.
  1. Select: the controller pulls the target's chip select low. Many devices treat the falling edge of CS as the start of a command.
  2. Clock and shift: on each clock, one bit leaves the controller on COPI and one bit leaves the target on CIPO. Most devices send the most significant bit first, but check the datasheet.
  3. Frame: there is no length field. The number of clocks while CS is low decides how many bits move. Typical commands are a byte or two followed by address and data bytes.
  4. Deselect: the controller releases CS high. On many devices this is what makes a write take effect, so a CS glitch mid-transfer corrupts the command.

Because data moves both ways at once, a read is really an exchange: the controller clocks out dummy bytes to clock the answer back in.

Clock Modes

ModeCPOL (Clock Idle Level)CPHAData Sampled On
Mode 0Low0Rising edge (first edge)
Mode 1Low1Falling edge (second edge)
Mode 2High0Falling edge (first edge)
Mode 3High1Rising edge (second edge)

Controller and target must use the same mode. Mode 0 and mode 3 are the most common; many serial flash and sensor parts accept either. A mode mismatch usually shows up as every byte shifted by one bit.

Dual and Quad SPI

Serial NOR flash and some displays extend SPI by using the data lines in both directions. Dual SPI moves two bits per clock on IO0 and IO1; Quad SPI moves four on IO0 to IO3, reusing the write-protect and hold pins. The command byte is usually still sent on one line, and the flash datasheet defines which commands switch to two or four lines. Analysers and host adapters must support the wider mode to capture or generate these transfers.

Where SPI Is Used

  • Boot and storage: serial NOR flash holding firmware or a BIOS, SPI EEPROMs and FRAM, SD cards in SPI mode.
  • Data converters: ADCs and DACs, where full-duplex streaming at several MHz matters more than addressing.
  • Displays: small TFT and OLED panels and their touch controllers.
  • Sensors and radios: accelerometers, gyroscopes, pressure sensors, Ethernet controllers and sub-GHz or 2.4 GHz radio modules.
  • Programming: in-system programming of SPI flash on a finished board, and loading FPGA configuration from flash.

Common SPI Faults and How to Find Them

SymptomLikely CauseWhat to Check
Every byte off by one bit, or reads as 0xFFClock mode mismatch between controller and targetCapture SCLK and data with an analyser and compare the sampling edge with the datasheet mode
Reads return 0xFF or 0x00 regardless of commandWrong chip select, CS not reaching the device, or CIPO not connectedConfirm CS goes low at the target pin during the transfer
Works slowly, fails at full clock rateLong wires or a weak driver; round-trip delay on CIPO exceeds half a clock periodLook at edge quality on an oscilloscope; shorten leads or lower SCLK
Two targets corrupt each otherA deselected target drives CIPO instead of releasing itWith CS high, CIPO from that target should float; check for a missing tri-state
Flash writes do not stickWrite-enable command missing, or CS released before the command completedDecode the command sequence: write enable, then program, then poll status
Quad reads garbage, single reads fineQuad mode not enabled in the flash status register, or IO2 and IO3 held by WP and HOLDRead the status register and check the quad-enable bit

Tools for Analysing and Decoding SPI

Watch tools listen to an existing bus and record every transfer with timestamps. Drive tools take the place of the controller or a target, to talk to a device before the firmware exists or to script production tests and flash programming.

Protocol Analyser

ProductRoleCapabilityPrice ex VAT
Total Phase Beagle I2C/SPI (TP320121)WatchNon-intrusive SPI monitor to 24 MHz (capture rate depends on the host PC), with I2C to 4 MHz and MDIO to 2.5 MHz on the same unit£400

Logic Analysers with SPI Decoding

The better choice when SPI is one of several signals you need to see together, such as an interrupt or reset line, or two buses at once.

ProductRoleCapabilityPrice ex VAT
Saleae Logic 8Watch8 channels, digital and analogue; SPI decoder in the Logic 2 software£405
Saleae Logic Pro 8Watch8 channels at higher sample rates; same SPI decoder£830
Saleae Logic Pro 16Watch16 channels, room to capture Quad SPI plus control lines (the built-in decoder is single SPI; a community QSPI analyser covers quad)£1,245

Host Adapters

ProductRoleCapabilityPrice ex VAT
Total Phase Aardvark (TP240141)DriveSPI controller 125 kHz to 8 MHz, target to 4 MHz; also I2C£335
Total Phase Cheetah (TP280121)DriveHigh-speed SPI controller, 0.1 MHz to 40+ MHz, up to 3 chip selects£475
Promira with SPI Active Level 1 (TP600510)DriveSPI controller to 12.5 MHz, target to 8 MHz, 1 chip select£120 plus the £1,040 Promira
Promira with SPI Active Level 2 (TP600610)DriveSingle and Dual SPI controller to 40 MHz, target to 20 MHz, up to 3 chip selects£245 plus the Promira
Promira with SPI Active Level 3 (TP600710)DriveSingle, Dual and Quad SPI controller to 80 MHz, target to 20 MHz, up to 8 chip selects£810 plus the Promira

Flash Programming and Test Targets

Browse every tool in our protocol decoders, logic analysers and host adapters collections. Not sure which fits your clock rate and voltage? Send us the target device and bus speed and we will recommend one.

Frequently Asked Questions

What Is the Difference Between SPI and I2C?

SPI uses a separate chip select per device and push-pull outputs, so it runs much faster, typically tens of MHz, and moves data both ways at once. I2C uses two shared wires with addresses and acknowledges, so it needs fewer pins and tells you when a device does not answer, but tops out at a few Mbit/s.

Which SPI Mode Should I Use?

The one in the target device datasheet. Look for the clock idle level (CPOL) and whether data is sampled on the first or second edge (CPHA). If the datasheet only shows a timing diagram, read the clock level while CS is high and the edge where data is stable.

Can SPI Have Several Controllers?

Not in normal use. SPI has no arbitration, so two controllers driving SCLK at once would collide. Systems that need it hand over control in software or through a separate signal.

How Fast Can SPI Run?

There is no protocol limit; the devices and wiring set it. Serial flash commonly runs at 50 MHz or more on a short PCB trace, while the same part on a ribbon cable to a test fixture may need a few MHz. The round-trip delay on CIPO is usually what fails first.

Do I Need a Protocol Analyser or Will a Logic Analyser Do?

A logic analyser with an SPI decoder shows commands and data alongside other signals and is enough for most bring-up work. A dedicated protocol analyser such as the Beagle I2C/SPI records long sessions as a searchable transaction list, which is faster when one bad transfer is hidden among thousands.

Where to Start with SPI

More Protocols

By John Legg CEng, Director, Debug Store. Updated 3 November 2026.