I2C and SPI Protocol
I2C is a two-wire synchronous serial communication protocol. SDA line is used for transferring data and SCK is used for transferring clock information. Every device connected to an I2C bus has a unique address. I2C communication protocol involves communication between a slave and a master. The device which initiates the communication and which provides the clock is referred to as a master device. The devices which receive the clock signal and receive/transmit data according to the clock signal is termed as a slave device. Each device on the bus is accessed using its slave address.
Communication process in an I2C bus
|START Bit||7-bit Slave Address||R/W#||ACK||8-bits of Data||ACK||8-bits of Data||ACK||P|
STEP-1) First the MCU will issue a START condition. The devices connected to the bus will listen to the START condition and will stay ready to begin the communication process.
STEP-2) Then MCU will send the address of the device with which it needs to communicate. Master indicates the action to be performed with the device whether to read or write along with the address.
STEP-3) All devices connected to the bus will receive the address and will compare it with its own address. If the addresses match with each other, the device will send back an ACKNOWLEDGEMENT signal to the master device. If they don’t match they will simply wait for the bus to be released with a STOP condition.
STEP-4) Once the MCU sends the address and corresponding device acknowledges, the MCU can start transmitting or receiving data.
STEP-5) When the data transmission or reception is complete, the MCU will stop communicating by sending a STOP condition.
STEP-6) STOP condition indicates that the bus is released and it can be used by any other master (if any) connected to the I2C bus.
After a master generate a start condition I2C bus will solely belong to it. The bus will be freed only if the master generate a STOP condition. Any other master connected to the bus can access the bus after a STOP is identified on the bus.
If the master device which uses the bus needs to communicate with a different slave it should generate a RESTART. Instead if it tries to stop current communication and then start again it may lose access to the bus. RESTART is nothing but a start signal without a stop in the bus.
Video Tutorial - How does I2C Protocol Works?
Communication in SPI protocol
Comparison of I2C and SPI Protocol
|Inter Integrated IC Communication (I2C)||Serial Peripheral Interface(SPI)|
|Requires only two lines SDA,SCL||Requires minimum four lines,SS,SDA(MOSI), SDI(MISO), SCL|
|Low Speed||Higher Speed|
|Half Duplex||Full Duplex|
|Additional Signal select lines not required if devices increases||Additional Signal select lines are required as devices increases|
|More Power required||Less Power Required|
|Multimaster can be used easily||Multimaster is difficult to implement|
- Created and Developed by Prof.Sujit Wagh, SKNCOE, Pune
- WikiNote Foundation