SPI/A whole conversation/A transaction
Lesson 8 of 14 · in 3D and VR

A transaction

A whole SPI conversation lives between chip select falling and chip select rising. To read a register you send a command and an address, then clock out bytes that carry nothing while the peripheral fills them in.

Lonely BinaryUpdated 2026-09-304 min readNo board required

View it in VR

Lesson 8 of the SPI course opens in a VR headset, on a table in front of you, and a voice starts three seconds after you arrive. Type this short address into the browser on a headset such as Meta Quest or Apple Vision Pro, and press Enter VR. No headset? Press Start the lesson: the same lesson, full screen.

learn.lonelybinary.com/vr/spi/8

SPI has no message format. What holds a conversation together is chip select: the controller pulls it low, moves some bytes, and lets it go high. That stretch is one transaction, and the peripheral takes everything inside it as one command.

Reading a flash

The Winbond W25Q128JV reads with instruction 0x03. With /CS low, the controller sends 0x03, then a 24-bit address as three bytes, biggest part first. The chip then shifts the data at that address out on MISO, most significant bit first. The address counts up by itself, so it goes on with the next byte and the next. The datasheet ends the instruction by driving /CS high.

To read two bytes from address 0x000010 the controller sends 0x03, 0x00, 0x00, 0x10, 0x00, 0x00. The first four bytes that come back mean nothing. The last two are the chip's data.

Why the empty bytes

Every clock moves a bit each way, and a peripheral cannot speak unless the controller clocks. So to read n bytes the controller clocks n bytes and puts anything at all on MOSI. Zero is the usual filler. It is called a dummy byte, and the peripheral ignores it.

That is a habit, not a rule. Some instructions want extra dummy clocks before the data starts, and the datasheet counts them. The W25Q128JV's 0x03 read has none.

The same frame, another chip

The Bosch BME280 does not use an instruction byte. The top bit of the register address is a read flag: to read register 0xF7 the controller sends 0xF7, and to write it, 0x77. The data follows straight away, and a longer read counts the address up. Even so, communication starts when CSB goes low and stops when it goes high.

Cutting it short

If chip select rises in the middle of a command, the peripheral drops it. Raise it after the address and before the data, and nothing has been read. Tie it low and there is no boundary at all: nothing marks where one conversation ends and the next begins.

Common mistakes

  • Letting chip select rise between the address and the data. The command ends there, and the read never happens.
  • Treating the bytes that come back during the command as data. The answer starts after the last command byte.
  • Sending a dummy byte where the datasheet wants clocks only. Some instructions count dummy clocks, not bytes, so read the timing diagram.

Edit this page — content/fundamentals/spi/a-transaction.mdx

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Fundamentals on the forum →