I2C vs SPI Communication Protocol Basic

I2C is one of the most popular protocol used in industry for many purposes. Here we will see the technical details of this protocol with its advantages and disadvantages.

I2C stands for:     
Inter-Integrated Circuit    
                                                              
Developed By:            
Philips, NXP

Used for:                    
Communication between different peripheral IC likes EEPROM, Flash, RTC, ADC.

Type:                           
Half Duplex - Synchronous Serial Protocol

Speed:                         


  • 100 kbps to 400kbps (Fast Mode)
  • 1Mbps (Fast-mode Plus) 
  • 3.4 Mbps (High-Speed Mode)
  • 5 Mbps (Ultra High-Speed mode)

Pin Configuration: Two Wire Protocol


  • SDA -Data 
  • SCL- Clock
Multi Master: Possible

Bus Arbitration:           
Yes, Lower Value get the bus, Zero Wins the Race (Based on Wire End           Operation)



Asynchronous vs Synchronous Communication


Before Going to I2C technical specification. You need to know the meaning of synchronous and asynchronous communication.

Asynchronous


You need to set the same baud rate at Transmitter and receiver end. You can observe the corrupted or garbage data if there is the mismatch in baud rate at both ends. Baud rate depends on is depend on clock frequency. 

Start and stop bits will be sent at the beginning and end of file transmission to synchronization. Parity bit (Even, Odd parity) is also sent along with the data. Xon/Xoff bit is used when communicating with the slower device in case of serial RS232 communication. 

Due to extra bits for a start, stop & parity bit, overhead in communication is high.



I2C:


I2C is half duplex communication so you cannot send and receive data at same time. that why it has only one data line SDA. In case of SPI which supports full duplex, you can have two separate lines for Tx and Rx. 

Master: 
A device which can initiate the transfer operation is the master device. Master device controls the bus and clock signal. Master generates the clock signals. 

Slave: 
A device which involve in communication with the master. A slave can not initiate the transfer of data. A slave can not generate the clock signal. 

Slave to slave communication is not possible as the slave can not initiate the transfer of data. 

Mode of Operation


If you are working on application level then you might not come across the I2C protocol. But If worked at lower layer then you should know about I2C.

I2C has two different modes of operation:


  • 7 bit Mode
  • 10 bit mode

You have 7 / 10 bits for addressing. So theoretical you can connect 2^7 and 2^10 device on the bus. But practically it is not possible to connect that much devices on the bus due to bus capacitance. 

Start / Stop Condition


In I2c, you have two lines; one is SDA (Data) and SCL (Clock). To indicate the start of a frame, you need to send the start condition. And at the end you need to send the stop condition to indicate the end of the frame. 

Start condition: It is indicated by pulse sequence - when Clock remains the high level and Data goes from High to Low.

Stop condition: It is indicated by pulse sequence - when Clock remains the high level and Data goes from Low to High.

Acknowledgement


As I2C support acknowledgement mechanism. I2C follow the predefined sequence to send out the data frame. To send out the data, you need to follow the below sequence in more generic case. It may deviate to some extent depending on the IC to which you are communicating. 


  • Start condition (Start of frame)
  • Device ID / Slave ID 
  • R/W (as I am half duplex communication)
  • Data
  • Acknowledgement
  • Stop
To indicate the acknowledgement slave pull down the data line to low on success. 

Arbitration


As i2c support multimaster configuration, arbitration comes into the picture. Arbitration is the mechanism by which it is decided that who get the bus in case of more than one master tries to access the bus.



                                                                                  
Share on Google Plus

About Kapil Thakar

"I am Kapil Thakar, an Embedded Engineer cum Blogger wants to learn new things. I love to share my knowledge solutions to the problems. Interested in Blogging, Creative-Writing, SEO, Website Creation, Video Making, Editing, Affiliation Programs, Online Making Money."
    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment

Related Posts Plugin for WordPress, Blogger...