Professional Documents
Culture Documents
(I C) Protocol
2
Rajesh Panicker
[T]EE2028
2
I2C Introduction
3
I2C Introduction
◼ Originally developed by Philips, became an industry
standard
◼ Motivation - lower pin count and hence lower
◼ IC manufacturing / packaging costs
◼ PCB complexity and cost
◼ Power and size
◼ Maximal bi-directional data bit rate:
◼ Standard-mode: 100 kbit/s
◼ Fast-mode: 400 kbit/s
◼ Fast-mode Plus: 1 Mbit/s
◼ High-speed mode: 3.4 Mbit/s
◼ Not all devices are capable of all the modes
◼ Many low-speed devices support only standard-mode
4
Common I2C Peripherals
To Do : Answer the
rest of the qns in
PCI-4 lab sheet
The devices highlighted above use I2C2 for data transfer. They also use GPIOs (EXTIs) for interrupts
6
I2C Signals
7
I2C Bus Protocol
◼ All transactions begin with a START S and can be terminated by a
STOP P, and are always generated by the master
Why is A specified to be a low, rather than a high during the 9th clock period?
10
Master Transmitter mode
PUPDR
AFR 0x01 REG_2
OTYPER …
.…
P
yyy SENSOR
I2C_CR1 U
N
SDA
..
I2C_ISR
P 0x00 CONTROL
ARM I2C_TXDR
D
N
and send values appropriately to meet the needs of the appln 7-bit SA = 0x44
◼ Many sensors give 16-bit readings and will have separate LSB and MSB
registers. How can we read 2 registers?
◼ Write LSB address, read value_LSB, write MSB address, read value_MSB
◼ Alternative: Autoincrement - reading multiple registers in one transaction
◼ The master reads two bytes in a single read transaction. The first byte is the
content of the register whose address was written in the preceding write. The
second byte is the content of the register with address++, i.e., a pointer
internal to the slave keeps track of which register is read, and increments it
with each byte read
◼ Only if the sensor supports it. May need to be enabled/configured explicitly
◼ Can be used for writing to multiple registers too, not just for reading
17
I2C Advantages
◼ Two lines reduce space, simplify circuit layout and reduces
packing and PCB complexity and costs
◼ Each slave device connected is uniquely addressable using slave
addresses - just two lines can support a fairly large number of
devices
◼ No strict baud rate specified since the clock is driven directly by
the master. This reduces the complexity of the circuit
◼ Multi master support (vast majority of the systems have only a
single master though)
◼ Very simple standardized protocol which can be emulated by
microcontrollers without integrated I2C peripheral devices
through GPIO. This is called bit-banging
◼ Supports up to 3.4 Mbits/sec transfer speeds
◼ ICs can be added to or removed from a system without affecting
any other circuit on the bus
18
I2C Disadvantages
◼ High protocol overhead – a lot of time is wasted sending slave
addresses, acknowledgements etc. (i.e., because of in-band
addressing)
◼ Not very fast compared to other protocols such as SPI / USB
◼ 7-bit addressing supports only a very small number of devices
◼ Different devices from different manufacturers come with hard
coded slave address or address will be configurable in a small
range only
◼ This can lead to address clashes
◼ No automatic bus configuration or plug and play
◼ Slower devices may stretch the clock thereby increasing latency
and keeping other devices waiting for access to the bus
◼ Only handles short distances (because of being synchronous)
compared to other standards such as RS-232, RS-485 or CAN
19
Questions?
20