Difference between I2C and SPI, you should know.

difference between I2C and SPI

There are a lot of serial communication protocol but in which I2C and SPI are very famous, In this article, I will discuss the difference between I2C and SPI. I2C and SPI are both bus protocol to allow the user for short-distance, serial data transfer. I2C is two wire communication which made by the Philips (Nowadays NXP) and SPI is made by the Motorola. Both protocols are commonly used in electronic devices like smartphone, TV, and laptops to control the peripheral like power management chips, memory devices, input device etc.

What is I2C?

I2C is a serial communication protocol. It provides the good support to the slow devices, for example, EEPROM, ADC, and RTC etc.I2c are not only used with the single board but also used with the other external components which have connected with boards through the cables.

I2C is basically two-wire communication protocol. It uses only two wire for the communication. In which one wire is used for the data (SDA) and other wire is used for the clock (SCL).

In I2C, both buses are bidirectional, which means master able to send and receive the data from the slave. The clock bus is controlled by the master but in some situations slave is also able to suppress the clock signal, but we will discuss it later.

Additionally, an I2C bus is used in the various control architecture, for example, SMBus (System Management Bus), PMBus (Power Management Bus), IPMI (Intelligent Platform Management Interface) etc.

To know the I2C in detail see this article: Understanding of I2C Protocol.

What is SPI?

The serial peripheral interface is four wire-based full duplex communication protocol these wire generally known as MOSI (master out slave in), MISO (master in slave out), SCL (a serial clock which produces by the master) and SS (slave select line which use to select specific slave during the communication).

SPI follows the master and slave architecture and communication is always started by the master. It is also synchronous communication protocol because the clock is shared by master and slave.

SPI is supported only multi-slave does not support multi-master and slave are selected by the slave select signal. In SPI during the communication data is shifted out from the master and shifted into the slave vice- versa through the shift register.

 

If you want to learn c language or any another programming language or technology, I recommend you to see the online courses on Pluralsight, 10 days trial is free.

C tutorial

 

 

In the embedded system, I2C and SPI both play an important role. Both communication protocols are the example of the synchronous communication but still, both have some important difference. In below table, I have pointed some common difference between I2C and SPI.

The important difference between I2C and SPI communication protocol.

                 I2C

                  SPI

 

I2C can be multi-master and multi-slave, which means there can be more than one master and slave attached to the I2C bus

 

SPI can be multi-save but does not a multi-master serial protocol, that means there can be only one master attached to SPI bus.

 

 

I2C is half-duplex communication protocol.

 

 

SPI is a full duplex commination protocol.

 

 

I2C has the feature of clock stretching, that means if the slave cannot able to send fast data as fast enough then it suppresses the clock to stop the communication.

 

 

Clock stretching is not the feature of SPI.

 

 

I2C is used only two wire for the communication, one wire is used for the data and the second wire is used for the clock.

 

 

SPI needs three or four wire for communication ((depends on requirement), MOSI, MISO, SCL and Chip-select pin.

 

 

I2C is slower than SPI.

 

 

In comparison to I2C, SPI is faster.

 

 

I2C draws more power than SPI.

 

 

Draws less power as compared to I2C.

 

 

I2C is less susceptible to noise than SPI

 

SPI is more susceptible to noise than I2C.

 

 

I2C is cheaper to implement than the SPI communication protocol.

 

 

Costly as compare to I2C.

 

I2C work on wire and logic and it has a pull-up resistor.

 

There is no requirement of pull-up resistor in case of the SPI.

 

In I2C communication we get the acknowledgment bit after each byte.

 

Acknowledgment bit is not supported by the SPI communication protocol.

 

 

I2C ensures that data sent is received by the slave device.

 

 

SPI does not verify that data is received correctly or not.

 

 

I2C support the multi-master communication.

 

 

SPI does not support multi -master communication.

 

 

I2C is a multi-master communication protocol that’s why it has the feature of arbitration.

 

 

SPI is not a multi-master communication protocol, so it does not consist the properties of arbitration.

 

 

I2C is the address base bus protocol, you have to send the address of the slave for the communication.

 

 

In case of the SPI, you have to select the slave using the slave select pin for the communication.

 

 

I2C has some extra overhead due to start and stop bits.

 

SPI does not have a start and stop bits.

 

 

I2C supports multiple devices on the same bus without any additional select lines (work on the basis of device address).

 

 

SPI requires additional signal (slave select lines) lines to manage multiple devices on the same bus.

 

 I2C is better for long distance.

 

SPI is better for the short distance.

 

I2C is developed by NXP.

 

SPI is developed by Motorola.



6 comments

  1. I2C is quite involved, supporting multiple masters on the bus. Which causes significant overhead in the bus protocol, an ACK for every byte and intentional delays to arbitrate access to the bus. Also a set maximum bus rate, 100 kHz in the original spec, 400 kHz is common today, additional 10 kHz low-speed and 3.4 Mhz high-speed modes, the 2012 spec defines a 5 Mhz ultra-fast mode.

    SPI is much simpler, a single master with no bus protocol beyond a chip select and no set maximum bus rate. If the distances are short then you can go as fast as you dare. Quite fast on an interconnect between chips that are less than an inch apart.

    Ref:https://stackoverflow.com/questions/21848629/what-makes-spi-faster-than-i2c-protocol

Leave a Reply