SPI introduction

Comparison between SPI and UART

So, you want to send the data from your controller to another. There are many ways you can do that. There are methods like UART, I2C to do the task. In this article, we are giving you the introduction of SPI communication, it’s advantages and disadvantages.

Till this point, I am assuming that you know UART and USART communication. It’s not necessary to understand them before continuing but, I would recommend to know it before because It would be easy to compare. Before continuing on SPI, let us understand some of the drawbacks of UART or USART.

The main drawback is the clock of the transmitter and the receiver should be “synchronized” with each other. More importantly, the baud rate (bits per second), of transmitter and receiver, should be the same.

The other disadvantage is the communication is possible between two devices only whereas in SPI and I2C, more than one devices can be connected with the host. The other thing is speed. It can be slower than the SPi and I2c. Now you know about the disadvantages of USART, let us now understand about SPI.

SPI-Serial Programming Interface

The only similarity between SPI and UART is that they both are serial otherwise, both are very different in implementation. Here clock signal utilizes a different bus. The clock signal is generated by only one side which is known as the “master” side. The clock signal guides the receiving end-“slave” about exactly when to sample the bits. Please do note that there can only be one master but multiple slaves can be present.

We need two buses for communication to be duplex. The bus that carries the data from the master to the slave is called MOSI(Master Output Slave Input) while the bus that carries the data from the slave to the master is called MISO(Master Input Slave Output). There is one more pin which enables the communication known as Slave Select(SS). It is used to initiate the communication between the master and slave. In the case of multiple slaves, there can be multiple “SS” pins which facilitate channel-like structure where one slave is listening or sending to the master at the time( Independent slave configuration), or if you connect the one SS pin to multiple slaves, they all can listen to the same data from the master at the same time(Daisy chain configuration).

Spi independent Slave Configuration
Independent slave configuration




Daisy Chain Configuration-SPI
  Daisy Chain Configuration

Events Occurred in SPI Data Transmission

  1. The master configures the clock up to few MHz.
  2. It then selects the slave side by activating it with logic-0
  3. Now the communication begins. Please do note that it is a full duplex communication. So data transmission can occur both ways at the same time.

Advantages of SPI Communication

Like every other communication protocol, it has some advantages and also some disadvantages. Let’s go through some of the advantages first-

  • No slave addressing system- unlike in I2C.
  • Higher data transmission rate.
  • Separate lines for MISO and MOSI which ensured the full duplex communication.

Disadvantages of SPI Communication

  • Uses more buses than UART and I2C.
  • No form of error checking like the parity bit in UART.
  • Only allows for a single master.

Applications of SPI Communication

SPI has a solid role in Embedded Systems. Microcontrollers like AVR, PIC includes SPI Controller capable of running in both the modes. AVR Controller can be programmed using s SPI Interface.

Some devices use the full-duplex mode of SPI for applications like digital signal processing, but most of the peripherals stick to the half-duplex request-response type protocol. It is also able to talk to a variety of peripherals such as-  sensors(temperature, pressure), Memory(Flash and EEPROM), Real-time Clocks, SD Cards etc.

Well, that’s it for now. In the coming article, we will implement this communication in AVR Microcontroller. If you have any comments or feedback to give, please do so in the comment box given below. See you next time!

Image Source-learn.sparkfun.com

Leave a Comment

Your email address will not be published. Required fields are marked *

Share This
Scroll to Top