SPI Is another serial communication interface. It stands for Serial Peripheral Interface. SPI is full duplex (it can send data in both directions at the same time due to having separate lines for data travelling in each direction: MISO and MOSI, like serial with its Rx and Tx) and uses a shared clock signal. It's high speed and designed for very short distance connections. Examples of SPI peripherals are SD Cards and LCD displays. If you're using any one the M0 Express boards, you'll be familiar with another use: external SPI flash chips. Finally, the ICSP connector on the Arduino UNO and the like is simply a SPI connector.  One thing I've used SPI for is to connect the nRFL01+ mesh radio board to '328 based boards. Basically it's great for high speed peripherals that aren't far from the MCU.

From the ATMega328 datasheet

The SPI main in the '328 is on the left and the secondary in the SPI device is on the right. Each side has an 8-bit shift register that moves data in and out, using the clock generated by the main.  That's pretty much it. The one other thing with SPI that you may have noticed is the select signal. Multiple SPI secondary devices can be connected to a single main, but each needs a unique select signal from the main to enable it. The select signal disables the shift register as well as putting its MISO output into 3-state mode, disconnecting it from the bus. This allows the main to select the one SPI secondary device that it wants to communicate with.

That's about it. SPI is a very simple communication system, much simpler than I2C. There is no addressability, the device being communicated with is selected using a hardwired signal line. This means that there is minimal overhead in the data, allowing it to be streamed at high speed. It also means that it's only feasible for use with a small number of devices.

This guide was first published on May 29, 2018. It was last updated on May 29, 2018.
This page (SPI) was last updated on Jul 02, 2020.