DEV Community

Raks2000
Raks2000

Posted on

I2C COMMUNICATION PROTOCOL

Hello all,
My name is Rakshith M working as a junior software engineer at Luxoft India. While working with some projects I was inspired to learn on I2C Communication protocol, and this is one of my interests so in this article I made my best effort to provide some information.

I2C stands for Inter-Integrated Circuit. It is a bus interface connection protocol integrated into devices for serial communique. It became at first designed with the aid of Philips Semiconductor in 1982. Recently, it is a widely used protocol for brief-distance conversation.

Working of I2C Communication Protocol:

It uses only 2 bi-directional open-drain strains for facts communique referred to as SDA and SCL. Both those lines are pulled high.

Serial Data (SDA) – Transfer of data takes location thru this pin.
Serial Clock (SCL) – It incorporates the clock sign.

Image description

I2C operates in 2 modes –
• Master mode
• Slave mode
Each facts bit transferred on SDA line is synchronized by means of an excessive to the low pulse of every clock at the SCL line.
According to I2C protocols, the facts line cannot change when the clock line is excessive, it could change only when the clock line is low. The 2 traces are open drain, subsequently a pull-up resistor is needed in order that the traces are excessive because the gadgets on the I2C bus are energetic low. The facts are transmitted inside the shape of packets which accommodates nine bits. The series of these bits are –
Start Condition – 1 bit.
Slave Address – eight bits
Acknowledge – 1 bit.

Image description

Start and Stop Conditions:

START and STOP may be generated by way of retaining the SCL line high and converting the extent of SDA. To generate START situation the SDA is changed from high to low at the same time as maintaining the SCL high. To generate STOP circumstance SDA is going from low to excessive while keeping the SCL high, as proven inside the parent underneath.

Image description

Repeated Start Condition:
Between each start and stop condition pair, the bus is considered as busy, and no master can take manipulate of the bus. If the grasp attempts to initiate a new switch and does now not need to launch the bus earlier than starting the brand-new switch, it troubles a new START condition. It is known as a REPEATED START situation.

Read/Write Bit:
An excessive Read/Write bit shows that the grasp is sending the records to the slave, whereas a low Read/Write bit indicates that the master is receiving statistics from the slave.
ACK/NACK Bit:
After each records body, follows an ACK/NACK bit. If the statistics frame is acquired efficaciously then ACK bit is dispatched to the sender via the receiver.

Addressing:
The cope with frame is the first body after the start bit. The deal with of the slave with which the master wants to talk is dispatched by means of the master to every slave linked with it. The slave then compares its very own cope with this cope with and sends ACK.

I2C Packet Format:
In the I2C communication protocol, the statistics is transmitted inside the shape of packets. These packets are nine bits long, out of which the first 8 bits are installed SDA line, and the ninth bit is reserved for ACK/NACK i.e., Acknowledge or Not Acknowledge with the aid of the receiver.

Features of I2C Communication Protocol:
Half-duplex Communication Protocol – Bi-directional communique is feasible but no longer simultaneously.
Synchronous Communication – The records are transferred in the form of frames or blocks.
Can be configured in a multi-grasp configuration.
Clock Stretching – The clock is stretched whilst the slave device isn't geared up to accept more statistics by means of preserving the SCL line low, therefore disabling the grasp to elevate the clock line. Master will not be able to increase the clock line because the wires are AND stressed and wait till the slave releases the SCL line to reveal it is ready to transfer subsequent bit.
Arbitration – I2C protocol helps multi-grasp bus gadget but more than one bus cannot be used simultaneously. The SDA and SCL are monitored through the masters. If the SDA is determined excessive while it turned into presupposed to be low, it will be inferred that any other master is lively and consequently it stops the transfer of information.
Serial transmission – I2C makes use of serial transmission for transmission of records. Used for low-speed verbal exchange.

STEPS OF I2C DATA TRANSMISSION

  1. The master sends the start condition to each linked slave by way of switching the SDA line from a high voltage level to a low voltage stage before switching the SCL line from excessive to low
  2. The grasp sends every slave the 7- or 10-bit cope with of the slave it desires to speak with, together with the examine/write bit.
  3. Each slave compares the cope with sent from the grasp to its personal cope with. If the address matches, the slave returns an ACK bit by using pulling the SDA line low for one bit. If the deal with from the master does now not suit the slave’s own address, the slave leaves the SDA line excessive. Four. The master sends or gets the information frame. five. After everybody has been transferred, the receiving device returns every other ACK bit to the sender to acknowledge a success receipt of the frame.
  4. To forestall the statistics transmission, the grasp sends a forestall condition to the slave with the aid of switching SCL excessive earlier than switching SDA excessive.

Advantages:
• Can be configured in multi-grasp mode.
• Complexity is decreased because it uses most effective 2 bi-directional lines (unlike SPI Communication).
• Cost-green.
• It makes use of ACK/NACK function because of which it has stepped forward errors coping with skills.

Limitations:
• Slower speed.
• Half-duplex communication is used within the I2C communique protocol.

Conclusion:
In this article I have written some of the information on I2C communication protocol I will continue this topic in my next article

Top comments (0)