Basics of The I2C Communication Protocol
Basics of The I2C Communication Protocol
SEARCH …
COMMUNICATION
PROTOCOL SUBSCRIBE
EMAIL ADDR
SUBSCRIBE
SDA (Serial Data) – The line for the master and slave
to send and receive data.
HOW I2C WORKS
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:
ADDRESSING
I2C doesn’t have slave select lines like SPI, so it needs
another way to let the slave know that data is being
sent to it, and not another slave. It does this
by addressing. The address frame is always the first
frame after the start bit in a new message.
READ/WRITE BIT
The address frame includes a single bit at the end
that informs the slave whether the master wants to
write data to it or receive data from it. If the master
wants to send data to the slave, the read/write bit is a
low voltage level. If the master is requesting data
from the slave, the bit is a high voltage level.
After all of the data frames have been sent, the
master can send a stop condition to the slave to halt
the transmission. The stop condition is a voltage
transition from low to high on the SDA line after a low
to high transition on the SCL line, with the SCL line
remaining high.
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.
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:
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 solve 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:
ADVANTAGES AND
DISADVANTAGES OF I2C
There is a lot to I2C that might make it sound
complicated compared to other protocols, but there
are some good reasons why you may or may not
want to use I2C to connect to a particular device:
ADVANTAGES
DISADVANTAGES
SHARE: