I2 Cgroup 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

I2C

Group 2

Viraj Dandekar 184130008


Shashank Jagtap 184130021
Amey Dhuri 184130010
Anirudh Prakash 184130002
Rutika Shinde 184131052
Viraj Dandekar 184130008

Introduction of I2C

I2C stands for Inter-Integrated Circuit. The inter-integrated circuit or I2C Protocol is
a way of serial communication between different devices to exchange their data
with each other. This is a type of synchronous serial communication protocol which
means that data bits are transferred one by one at regular intervals of time set by a
reference clock line. It is a half-duplex bi-directional two-wire bus system in which
data transmission takes place between Masters and Slaves. It was originally
designed by Philips Semiconductor in 1982. Recently, it is a widely used protocol for
short-distance communication.

Features

The following are some of the important features of I2C communication protocol:

• Only two common bus lines (wires) are required to control any device/IC on
the I2C network

• No need of prior agreement on data transfer rate like in UART


communication. So the data transfer speed can be adjusted whenever
required

• Simple mechanism for validation of data transferred

Uses 7-bit addressing system to target a specific device/IC on the I2C bus

Each I2C device (Master/slave) is identified by its 7-bit or 10-bit unique address
known as device ID which is provided by device manufacturer only and can act as
a transmitter or receiver at a time, depending on the configuration of it. As we
know, the bus consists

The two common bus lines are Serial clock line or SCL and Serial data line or SDA.
It is also known as Two Wired Interface (TWI).
Master is the one which initiates a communication, generates a clock and
terminates the communication and Slave is the one which is handled by master
and acts according to the master command

Here SCL (serial clock line) is responsible for synchronizing the communication and
is controlled by Master and SDA (serial data line) is responsible for providing the
data bi-directionally and can be used by master or slave or both.

I2C networks are easy to scale. New devices can simply be connected to the two
common I2C bus linesOwing to its simplicity, it is widely adopted for
communication between microcontrollers and sensor arrays, displays, IoT devices,
EEPROMs etc.

Need of I2C Protocol Over Other Protocols

I2C combines the best features of SPI and UARTs. Before I2C, different devices used
to communicate using UART and SPI protocols

As UART is an asynchronous communication protocol which doesn’t use any clock


source for synchronizing the data, so there are more chances of losing the data over
UART protocol. In UART only two devices can communicate with each other over a
UART bus, it is not well suited for multiple devices communication. The highest data
rate UART can support is 230 kbps–460 kbps which was still a low speed as per the
requirements.

SPI is a minimum of 4 wire interface which is a major drawback for today’s


electronics demand where everything is going to be in a very compact form. It’s a
huge loss for a cheap controller which has a smaller number of pins. SPI is a single-
master multi-slave protocol; it cannot support multiple masters communicating
with multiple slaves.
With I2C, you can connect multiple slaves to a single master (like SPI) and you can
have multiple masters controlling single, or multiple slaves. This is really useful
when you want to have more than one microcontroller logging data to a single
memory card or displaying text to a single LCD.

Modes

There are mainly four modes which define the data rate of the I2C
communication system:

Shashank Jagtap 184130021


I2C packet

● Data is transferred between the master device and slave devices through a single
SDA data line, via patterned sequences of 0’s and 1’s (bits).With I2C, data is
transferred in messages.
● Messages are broken up into frames of data. Each message has an address frame
that contains the binary address of the slave, and one or more data frames that
contain the data being transmitted.
● The message also includes start and stop conditions, read/write bits, and
ACK/NACK bits between each data frame:
Start Condition
The SDA line switches from a high voltage level to a low voltage level before the SCL line
switches from high to low.Once a start condition is sent by the master device, all the slave
devices get active even if they are in sleep mode, and wait for the address bits.

Address frame
It comprises of 7 bits and are filled with the address of the slave device to/from which the
master device needs send/receive data. All the slave devices on the I2C bus compare
these address bits with their address.

Read/Write Bit
This bit specifies the direction of data transfer. If the master device/IC need to send data
to a slave device, this bit is set to ‘0’. If the master IC needs to receive data from the slave
device, it is set to ‘1’.

ACK/NACK Bit
Each frame in a message is followed by an acknowledge/no-acknowledge bit. If an
address frame or data frame was successfully received, an ACK bit is returned to the
sender from the receiving device.

Data Frames
It comprises of 8 bits and they are set by the sender, with the data bits it needs to transfer
to the receiver. This block is followed by an ACK/NACK bit and is set to ‘0’ by the receiver
if it successfully receives data. Otherwise it stays at logic ‘1’.

Stop Condition
After required data blocks are transferred through the SDA line, the master device
switches the SDA line from low voltage level to high voltage level before the SCL line
switches from high to low.
Dhuri Amey 184130010
STEPS OF I2C DATA TRANSMISSION

1. The master sends the start condition to every connected slave by switching the

SDA line from a high voltage level to a low voltage level before switching the SCL

line from high to low:

2. The master sends each slave the 7 or 10 bit address of the slave it wants to

communicate with, along with the read/write bit:

3. Each slave compares the address sent from the master to its own address. If the

address matches, the slave returns an ACK bit by pulling the SDA line low for one
bit. If the address from the master does not match the slave’s own address, the

slave leaves the SDA line high.

4. The master sends or receives the data frame:

5. After each data frame has been transferred, the receiving device returns

another ACK bit to the sender to acknowledge successful receipt of the frame:
6. To stop the data transmission, the master sends a stop condition to the slave by

switching SCL high before switching SDA high:


Anirudh Prakash 184130002
Masters and Slaves play an important role in I2C communication. Master is the one
which initiates a communication, generates a clock and terminates the
communication and Slave is the one which is handled by master and acts
according to the master command.
I2C protocol can be used in two configurations: Single master multiple slave and
multiple master multiple slave config.

SINGLE MASTER WITH MULTIPLE SLAVES

Because I2C uses addressing, multiple slaves can be controlled from a single
master. As in I2C protocol the size of the address is upto 10 bits, there can be a
maximum of 1,024 (210) unique addresses. Hence a single master device can be
connected to upto 1024 peripheral slave devices. Since communication is always
initiated by the master there is no chance of collision of data. The master would
send the address of the slave it wants to communicate with, to all of the slave
devices simultaneously through the SDA line and only the slave whose address
matches would send an ACK signal.To connect multiple slaves to a single master,
wire them like this, with 4.7K Ohm pull-up resistors connecting the SDA and SCL
lines to Vcc:
MULTIPLE MASTERS WITH MULTIPLE SLAVES

Multiple masters can be connected to a single slave or multiple slaves. The problem

with multiple masters in the same system comes when two masters try to send or

receive data at the same time over the SDA line. To overcome this problem, each

master needs to detect if the SDA line is low or high before transmitting a message.

If the SDA line is low, this means that another master has control of the bus, and

the master should wait to send the message. If the SDA line is high, then it’s safe to

transmit the message. To connect multiple masters to multiple slaves, use the

following diagram, with 4.7K Ohm pull-up resistors connecting the SDA and SCL

lines to Vcc:
Rutika Shinde 184131052
There is a lot to I2C that might make it sound complicated compared to other

protocols, but there are some good reasons why we use I2C to connect to a

particular device:

ADVANTAGES OF I2C

As a communication protocol, I2C has the following advantages:

● It only requires two signal (Buses)wires:- SCL & SDA

● Supports multiple masters and multiple slaves

● Each device on the bus is independently addressable.

● To improve the error detection and correction mechanism, the I2C

protocol relies on the ACK/NACK feature, which is a robust error correction

feature. ACK stands for Acknowledgement whereas NACK means No

Acknowledgement.

● Hardware is less complicated than with UARTs

● It is capable of handling multiple primary communications by providing

arbitration( If 2 or more masters are talking on a single bus at a time then

the slaves will not be able to understand any of the information. So to avoid

that bus arbitration is used in I2C communication) and communication

collision detection.

● I2C protocol is adaptable in the sense that it can work well with both slow

ICs and fast ICs.

● Well known and widely used protocol


DISADVANTAGES OF I2C

I2C communication doesn’t have too many disadvantages. The fact that the
protocol has been in use for over 30 years. However, it suffers from a few minor
limitations.

● Slower data transfer rate than SPI

● It provides a half-duplex mode for communication, since there is only

one line for communication between slave and master to transfer and

receive data

● The size of the data frame is limited to 8 bits.

● More complicated hardware needed to implement than SPI

● Since only 7-bits (or 10-bits) are available for device addressing, devices

on the same bus can share the same address. Some devices can

configure the last few bits of the address, but this imposes a limitation of

devices on the same bus.

Despite these minor limitations, I2C is a robust and desirable protocol. It


achieves exactly what it was meant to - facilitate low-speed communication.

APPLICATIONS OF I2C

I2C is a great option for applications that require low cost and simple

implementation rather than high speed. For example, common uses of the I2C

communication protocol include:

● Reading certain memory ICs.

● Accessing DACs and ADCs.

● Transmitting and controlling user-directed actions.

● Reading hardware sensors.

● Communicating with multiple micro-controllers.

You might also like