HOME . LEARN IOT . SPI

SPI

The Interface

SPI (Serial Peripheral Interface) is another protocol for connecting IoT devices. Its interface consists of 4 single-ended lines that serve different purposes. The lines are:

Master Out, Slave In (MOSI): This is the line over which the master send data to the slave(s). The Serial Peripheral Interface(SPI) is a simple peer-to-peer interface based on master-slave principle(master controls how the line is used). This interface provides a full-duplex communication between the master (usually a microcontroller) and one or more slaves (usually peripheral devices).

Master In, Slave Out (MISO): The slave uses this line to transmit data to the master.

System Clock (SCK): The master transmits clock signals over this line.

Slave Select (SS): The master selects a specific slave with this line.

Since SPI supports more than one slave in a network, there has to be a way to select the specific slave the master intends to communicate with. This is done by pulling the SS line low for the specific slave peripheral. This means it is held HIGH when a slave is not being addressed. This is sufficient for dealing with only 2 slaves. In this case, one slave's signal is passed through a NOT gate to invert it while the other goes directly. For it to be possible to connect multiple slaves, an external decoder is employed at the cost of losing some I/O pins on the master. In a later article we will look at how this is done.

In order to send a stream of 8 bits to a slave, the master loads the bits into a shift register connected to the interface. It then selects the specific slave by pulling its SS low. The data is moved on to the MOSI lines; after eight pulses the eight bits are transferred to the slave.

Advantages of SPI

● It's faster than asynchronous serial
● The receive hardware can be a simple shift register
● It supports multiple slaves

Disadvantages of SPI

● It requires more signal lines (wires) than other communications methods
● The communications must be well-defined in advance (you can't send random amounts of data whenever you want)
● The master must control all communications (slaves can't talk directly to each other)
● It usually requires separate SS lines to each slave, which can be problematic if numerous slaves are needed.

SPI is generally used for programming microcontrollers.

Author
Rene Novor X.K
Mor-Lan Technologies.

References
https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/

How we Work

At Mor-Lan Technologies, we aim at developing the best solution to the most pressing problems we face here in Ghana and Africa at large when it comes to information technologies. Producing high quality products is our focus here!