SPI (Serial Peripheral Interface) bus was originally developed by Motorola for use with their microcontrollers. Due to the simplicity of the bus, other manufacturers adopted it and it has become widely available in components used in embedded system designs. It is commonly used for chip-to-chip communications between a CPU and keyboard, display, ADCs and DACs, real-time clocks, EEPROM, SD and other memory devices.
SPI is a synchronous bus with four lines: Data - master output/slave input (MOSI) and master input/slave output (MISO), clock (SCLK), and slave select (SS or CS). SPI is a full duplex standard, meaning signals can be transmitted in both directions simultaneously, with data rates from a few Mb/s to tens of Mb/s.
Devices communicate using a master-slave architecture with a single master. The master device initiates the frame for reading and writing. Multiple slave devices can be addressed with individual slave select lines.
SPI waveforms can be decoded with PicoScope: From the Tools menu select Serial Decoding then Create and select SPI from the list of available protocols.
The SPI bus is a master/slave, 4-wire serial communications bus. The four signals are Data - master output/slave input (MOSI), master input/slave output (MISO), clock (SCLK), and slave select (SS or CS).
Whenever two devices communicate, one is referred to as the "master" and the other as the “slave”. The master drives the serial clock. Data is simultaneously transmitted and received, making it a full-duplex protocol. SPI uses the SS (or CS) line to specify which device data is being transferred to or from, so each unique device on the bus needs its own SS signal from the master. If there are 3 slave devices, there are 3 SS lines from the master, one to each slave.
To begin communication, the bus master configures the clock, using a frequency supported by the slave device, typically a few MHz or tens of MHz. The master then selects the slave device with a logic level 0 on the select line.
During each SPI clock cycle, a full duplex data transmission occurs. The master sends a bit on the MOSI line and the slave reads it, while the slave sends a bit on the MISO line and the master reads it.
Transmissions involve two shift registers of a given word size, such as eight bits, one in the master and one in the slave. Data is usually shifted out with the most-significant bit first, while shifting a new least-significant bit into the same register. After the register has been fully shifted out the master and slave have exchanged register values. If more data needs to be exchanged the shift registers are reloaded and the process repeats. Transmission may continue for any number of clock cycles. When complete, the master stops toggling the clock signal, and deselects the slave.
The master device must select only one slave at a time. Slave devices on the bus that have not been activated using their chip select line must disregard the input clock and MOSI signals, and must not drive MISO.
To decode SPI data first acquire the packets of interest using PicoScope. Then select Serial Decoding from the Tools menu.
Click Create and select SPI from the list of available protocols.
Select the corresponding PicoScope input channels in the SPI configuration menu for Data (MOSI / MISO), Clock, Slave Select (SS). Set any other parameters as necessary. Click OK to see the decoded SPI packets in the PicoScope graph display.
For more information on PicoScope's serial decoding capabilities, see Serial bus decoding and protocol analysis - overview.