Skip to content
systemcoding.dev
Hardware

Decode SPI in PulseView with the spi protocol decoder

Decode a captured SPI bus in PulseView by adding the SPI decoder and mapping CLK, MOSI, MISO and CS#, then match CPOL and CPHA to the chip.

2 min read
Summarize in AI

A raw SPI capture is four wavy lines until a decoder turns it into bytes. In PulseView 0.4, click the Decoders button, pick SPI, and the decoder appears as a row under the signals. Click its name to assign a channel to each role: Clock, MOSI, MISO and CS#. The decoder then prints the bytes above each transfer.

Two options in the decoder's settings decide whether the output is right. Clock polarity and clock phase must match the device, which is CPOL and CPHA in its datasheet. Get them wrong and the decoder still prints bytes, shifted by a bit, which looks like a real protocol problem and is not one. Set the chip-select polarity to active low unless your device says otherwise, and leave the bit order at MSB first for nearly every part.

The same decoder runs from the command line, which is handy for scripted checks on a saved capture:

Shell
sigrok-cli -i spi.sr -P spi:clk=D0:mosi=D1:miso=D2:cs=D3:cpol=0:cpha=0

The option names match the settings in the dialog. Try the other three mode combinations when the first one gives nonsense, and compare against a command whose reply you know, such as a flash chip's JEDEC ID read, which starts with 9F on MOSI.

If the output only decodes when CS# is mapped, the capture started mid-transfer. Without a chip-select channel the decoder cannot tell where one word ends, so map it whenever you have wired it.

Also inDebugging
Share

More snippets

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.