Working with I2C bus
The I2C bus was designed by Philips in the early 80 to allow easy communication between components which reside on the same circuit board. Philips Semiconductors migrated to NXP in 2006. Sometimes the bus is called IIC or I²C bus.
- Only two bus lines are required
- No strict baud rate requirements like for instance with RS232, the master generates a bus clock
- Simple master/slave relationships exist between all components
Each device connected to the bus is software-addressable by a unique address - I2C is a true multi-master bus providing arbitration and collision detection
The interface uses 8 bit long bytes, MSB (Most Significant Bit) first, with each device having a unique address. Any device may be a Transmitter or Receiver, and a Master or Slave. The Slave is any device addressed by the Master. A system may have more than one Master, although only one may me active at any time.
Data and clock are sent from the Master: valid while the clock line is high. The link may have multiple Masters and Slaves on the bus, but only one Master may be active at any one time. Slaves may receive or transmit data to the master.
The example shows how to interface I²C with 8051. Use the SDCC as C Compiler.Set P2.6 as SCL and P2.7 as SDA.
Datasheet
I²C-Bus Specification [pdf]
Source Code (For SDCC)
- i2c.h
I wish to share a link worthy for making a money of blogging...
ReplyDeletekeep blogging....
Blogging To The Bank 3.0 Reviewed