SPI vs SPI – Serial Peripheral Interface

SPI vs SPI – Serial Peripheral Interface

The UART serial communication method discussed in my last post showed a limitation of scale.  Asynchronous serial data should only be point to point.  If many devices are required, the complexity of design and cost increase.

The Serial Peripheral Interface, or SPI protocol, is a method to reduce the complexity and costs of scaling.  In contrast to UART, SPI does not require complex bridgeheads.  Receiving devices need nothing more than a shift register to operate.

Without going into too much detail about shift registers, they simply take serial data and assemble it into a parallel data.  There is plenty of more information available about shift registers.

Another difference that makes SPI unique from UART is it uses a channel to transmit an oscillating digital signal.  This is a clock signal and it’s used as a reference by the receiving device.  When a receiving device detects changes of highs and lows on its data port, it references the clock signal when to determine if the data is a high or low state.  The clock channel is often refereed to as CLK or SCK.  It does require an additional channel, but the clock frequency is adjustable and only needs to be generated from one device, the master.

Since SPI isn’t confined to point to point links, devices will come in two classes, either Master or Slave.  Like UART, data can only travel in one direction.  The sending master device uses one channel to the receiving slave device.  The slave then replies back to the master using another channel.  These channels are referred to MOSI (Master Out Slave In) and MISO (Master In Slave Out).

The number of slave devices is determined by another communications channel called the Slave Select, mostly called SS.  The master typically has a unique SS channel to each slave.  When the master needs to link to a slave, it changes the state of the SS channel and that slave device activates.  The only limit on the number of slaves a master can communicate with is dependent on the number of SS channels available.  Another device can be used to increase the limitation of a master’s available SS channels, this is called a line decoder.

Some instances of SPI support daisy chaining slaves to the master.  This typically is found in LED displays that act as data relays from the master.  The master controller activates a single SS channel to all devices.  This activates all the slave devices to expect data.  Then the master sends its data to the first slave through the MOSI port.  The first slave then forwards data to the next slave with the first slave’s MISO port and the second slave’s MOSI port.  This process continues until the last slave’s MISO port links back to the master.

I had used SPI to control several LEDs contained in a tail light on my bike.  The project let me turn on the tail light and increase its brightness when the breaks were used.  It also let me use the tail light as a turn signal.

At any point, this is pretty much what SPI is and a good foundation for understanding how it works.  We’ll be relying on this for more advanced topics later.  Thank you once again and I look forward to having you back.

Comments are closed.