How The SPI Protocol Works

How The SPI Protocol Works

What is SPI Protocol?

SPI-Serial Peripheral Interface

It features full-duplex communication and comes with a faster data transmission speed than I2C and UART.

spi full-duplex communication
Normally, SPI can achieve 1 Mbps at least on Arduino, while I2C can only reach 400 Kbps at most.
SPI Speed spi speed on Arduino

And the SPI protocol is simple and easy to use. There are abundant ready-to-go libraries for using SPI on Arduino.


In addition, multiple SPI devices can be supported through chip selection, which requires relatively fewer hardware resources and low costs


The SPI interface was developed by Motorola in the mid-1980s.

But since it is a de-facto standard based on facts, there are no officially defined and adopted standards for it.

For instance, SPI communication has four transmission modes that can be freely chosen by users based on the actual situation.

spi four transmission modes
SPI should only be used for short-distance data transfer, primarily in inter-chip communication.

It doesn't support plug-and-play(dynamic addition of nodes), and generally, there can be only one controller. Multiple devices can co-exist by chip selection, but that also means more complex connections. Besides, SPI has a high demand for wire routing because of its high transmission speed. Poor design may cause communication interrupts or data errors.

A Full-duplex Synchronous Serial Communication Protocol

Here let's get to know these keywords one by one. "Full-duplex" means it can transmit and receive data simultaneously, just like UART. So it needs at least two communication lines.

The word "synchronous" shows it has a clock line to synchronize the communications on both sides, just like I2C.
spi i2c

And "serial" indicates the data transmission is implemented via serial communication, which is the same as I2C and UART. By the way, there is another method for data transmission, parallel communication. Different from the serial, data bits are simultaneously transmitted through multiple communication links in parallel communication.

spi data transmission
Well, go back to SPI. Let's see how it works. SPI uses controller-peripheral architecture usually with a single controller and multiple peripherals. Typically, all SPI devices require at least four wires: PICO (peripheral in/controller out), POCI (peripheral out/controller in), SCLK(Serial Clock), CS(Chip Select)
spi four wires

How Does Communication in SPI Work?

First, the controller needs to choose which peripheral it wants to talk to.

spi work spi peripheral

Chip select pins are connected to different peripherals correspondingly. Then a peripheral can be selected by changing its CS signal from high to low. And other unselected peripherals will ignore the incoming SCLK and PICO signals, and also not send signals via POCI. After the peripheral is determined, the data transmission starts. As mentioned before, SPI uses a clock line to synchronize the transferred data bits.

spi clock line

When the transmission mode is selected, signals can be transferred via PICO and POCI at the same time on the rising or falling clock edge, just like two trains running toward each other.

spi PICO and POCI

Here we take 8 bits as a communication period.

This data exchange will be done after one period. Then chip selection and data transmission start again. After completing the data transfer, the controller stops transmitting SCLK, and the CS signal returns from low to high.

spi transfer


Next, let's see how to use SPI. Here we use a 6-Axis IMU module, microSD card, LCD screen and DFRobot FireBeetle ESP32-E make a recorder.

DIY A Simple Three-axis Accelerometer Data Logger

spi recorder spi recorder

Well, that's all about SPI. Feel free to add more information in the comments. Thanks for reading. If you like the article, please forward this page to your friends if you think they are helpful!

More Documents