Each I2c compatible device comes with a predefined address.
Device address can be 7 bit or 10 bit.Device address is availabe in Data sheet.
There is no voltage conversion in I2C unlike UART uses TTL logic only.
I2C is an acknowledgement based Protocol.
Device speed
I²C device Minimum speed is 100 kbps and maximum 3.4 MBps.if master is using
-100kbps it is called Standard speed mode
-400kbps it is called Fast speed mode
-1 MBps it is called Fast speed plus mode
-3.4 MBps it is called Hish speed mode
Byte Format and Byte Order
Every byte put on SDA must be strictly 8bit long,Data is transferred from MSB to LSB.
We cannot connect 2 slaves with same device address on I2C bus.
Download I²C Datasheet by NXP Semiconductors
Standard Write Frame(1 Byte)
Standard ReadFrame(1 Byte)
For reading I2C first we have to dummy write this is for checking whether device address is valid or not.
- Start Condition
- Stop Condition
- Write
- Read
- Acknowledgement condition
- No Acknowledgement condition
When master and slave are not communicating with each other the the bus is treated as idle ie. HIGH
I2C Start and Stop Condition
A high to low transition on the SDA line while SCL is high is reffered to as Starting Condition.
A low to high transition on the SDA line while SCL is high is reffered to as Stop Condition.
This is shown in the diagram below.
Protocol Implementation
There are two methods to implement Protocols
- Bit Banging Method.
- Peripheral Method.
Peripheral method is preferable since it has inbuilt protocol implementation logic in Micro controller.
If inbuilt I2C is not available ie no SDA or SCL lines we go for Bit Banging method for example 8051.
Bit Banging increases complexity in circuit and also correctness will be less.
Any I/O pins of the device can be connected to I2C device.The main disadvantage of using this method is that we cannot set the communication speed.
I have an 8051 development board with me, so here i am going to use bit banging method.
Use these header files in your Program for I2C Bit banging logic,I have done using KEIL IDE.
Download
I²C.h
I²C_device.h
check this sample program also to write string "NITHIN" to EEPROM - AT24C08 and then fetching it and printing on LCD
ASSIGNMENTS
* Write a Program to enter a character and enter a memory loacation and copy that character to that memory location.
<< Previous Next>>
0 on: "I²C PROTOCOL-Read & Write frame"