Tutorials

Learn More

An SPI transaction is the complete communication window between one controller and one selected peripheral. In most systems, the transaction begins when the controller asserts CS/SS, continues while the controller toggles SCLK, and ends when the controller stops the clock and deasserts CS/SS.

The important idea is this: SPI is clock-driven, not message-driven. The peripheral does not independently send a response whenever it wants. The controller must keep generating clock cycles, and on every clock cycle both sides can shift one bit. The controller sends one bit on MOSI, the peripheral sends one bit on MISO, and both sides sample according to the selected SPI mode.

SPI does not define one universal packet format. The bus defines the signal behavior; the peripheral datasheet defines the meaning of the clocked bits. Those bits may represent command, address, dummy, status, or data fields.

Transaction Vocabulary

TermSimple Meaning
BitOne value shifted on MOSI or MISO during a clock cycle
WordA group of bits shifted as a unit, commonly 8 bits but not always
TransferOne continuous clocked movement of one or more words
TransactionThe complete selected operation framed by CS/SS
Dummy bitsBits sent mainly to create clock cycles for receiving data
PhaseA logical part of a transaction, such as command, address, dummy, or data

Transaction Flow Diagram

The transaction flow diagram shows the controller-side view of one complete SPI operation. Read it from top to bottom: configure the transfer, select one peripheral, wait if the device requires setup or ready time, clock one word, shift and sample bits, repeat for more words if needed, stop the clock, and release CS/SS.

The More Words? step matters because many SPI operations are multi-byte. For example, a read from a memory-like peripheral may require a command byte, address bytes, dummy clocks, and then returned data, all while CS/SS remains active.

spi-transaction-flow-diagram

Step-by-Step Flow

StepWhat HappensWhy It Matters
1. ConfigureController sets mode, clock speed, word size, bit order, and target peripheralThe controller and peripheral must agree on timing before bits are exchanged
2. Select peripheralController drives CS/SS active for one peripheralOnly the selected peripheral should respond and drive MISO
3. Wait if requiredController waits before clocking if the device needs setup, ready, or conversion timeSome peripherals need time after selection before valid clocking begins
4. Clock one wordController generates the required SCLK pulses for one wordNo clock means no SPI data movement
5. Shift and sampleOne bit moves on MOSI and one bit moves on MISO during each clock cycleThis is the full-duplex heart of SPI
6. More words?Controller reloads/continues shifting if the transaction has more command, address, dummy, or data wordsMulti-byte transactions remain inside the same selected window when required
7. Stop clockController stops toggling SCLK and returns it to the idle levelThe clocked portion of the exchange is complete
8. Deassert CSController releases the peripheralThe transaction ends; many peripherals latch, commit, or reset parser state here

What Happens Inside One Clocked Word?

During a clocked word, both devices behave like linked shift registers:

  1. The controller places or shifts the next output bit onto MOSI.
  2. The peripheral places or shifts the next output bit onto MISO.
  3. On the configured sampling edge, both sides capture the incoming bit.
  4. The bit counter advances.
  5. The process repeats until the word is complete.

After one word is complete, the controller may stop or continue with another word. If more data needs to be exchanged, both sides conceptually reload or continue their shift registers, and the controller keeps generating clocks.