We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16
I2C
PROTOCOL
SWIPE I2C stands for inter integrated circuit.
It is a synchronous communication protocol
It is used to send data between multiple
devices.
It is organized into a master and slave
configuration.
The master has control over the slaves and the
slaves receive instruction from the master.
I2C is really useful when you want to have
more than one microcontroller logging data to a single memory card or displaying text in a display. I2C only uses two wires to transmit data between devices: SDA (Serial Data) – The line for the master and slave to send and receive data. SCL (Serial Clock) – The line that carries the clock signal. I2C is a serial communication protocol, so data is transferred bit by bit along a single wire (the SDA line). The output of bits is synchronized to the sampling of bits by a clock signal shared between the master and the slave. The clock signal is always controlled by the master. How I2C works ? 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.
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.
Stop Condition: The SDA line switches from a
low voltage level to a high voltage level after the SCL line switches from low to high. Address Frame: A 7 or 10 bit sequence unique to each slave that identifies the slave when the master wants to talk to it.
Read/Write Bit: A single bit specifying whether
the master is sending data to the slave (low voltage level) or requesting data from it (high voltage level).
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.
I2C doesn’t have slave select lines like SPI. It
does this by addressing. The address frame is always the first frame after the start bit in a new message. STEP 1
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. STEP 2
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. STEP 3
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. STEP 4
4. The master sends or receives the data frame.
STEP 5
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. STEP 6
6. To stop the data transmission, the master
sends a stop condition to the slave by switching SCL high before switching SDA high SINGLE MASTER WITH MULTIPLE SLAVES
With a 7 bit address, 128 (27) unique address are
available. Using 10 bit addresses is uncommon, but provides 1,024 (210) unique addresses. 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 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: EXAMPLE