Documente Academic
Documente Profesional
Documente Cultură
I2C INTRODUCTION
Multi-master serial single-ended bus developed by Philips , is used to attach lowspeed peripherals to a motherboard, embedded system, cell phones etc
I2C PROTOCOL
2 wire Interface communication. Ie 2 active wires SDA (data line ) -- SCK (clock line). Both are bidirectional bus.
ADDRESSING
Each device has unique address, no matter whether it is an MCU, LCD driver, memory, or ASIC. Each of these chips can act as a receiver and/or transmitter, depending on the functionality Two mode of addressing
7 bit addresing -127 devices can be connected to bus 10 bit addressing - 1024 devices
MODE OF COMMUNICATION
Multi-master mode of communication. Device act as both slave and master, No slave select pin , addressing is used to identify each devices. 4 -Mode of communication:
ACK Restart
TIMING DIAGRAM
Start and stop condition
soon as the master pulls SCL low to complete the transmission of the byte (1), SDA will be pulled low by the slave (2).
The master now issues a clock pulse on the SCL line (3). the slave will release the SDA line upon completion of this clock pulse (4).
I2EN I2C Interface Enable. When I2EN is 1, the I2C interface is enabled. When I2EN is 0, the SDA and SCL input signals are ignored. STA is the START flag. Setting this bit causes the I2C interface to enter master mode and transmit a START condition or transmit a repeated START condition if it is already in master mode. STO is the STOP flag. Setting this bit causes the I2C interface to transmit a STOP condition in master mode, or recover from an error condition in slave mode SI is the I2C Interrupt Flag. This bit is set when the I2C state changes. AA is the Assert Acknowledge Flag. When set to 1, an acknowledge (low level to SDA) will be returned during the acknowledge clock pulse on
The I2CONCLR registers control clearing of bits in the I2CON register that controls operation of the I2C interface. Writing a one to a bit of this register causes the corresponding bit in the I2C control register to be cleared
Writing a 1 to this bit clears the AA bit in the I2CONSET register. Writing 0 has no effect. SIC is the I2C Interrupt Clear bit. Writing a 1 to this bit clears the SI bit in the I2CONSET register. Writing 0 has no effect STAC is the Start flag Clear bit. Writing a 1 to this bit clears the STA bit in the I2CONSET register. Writing 0 has no effect. I2ENC is the I2C Interface Disable bit. Writing a 1 to this bit clears the I2EN bit in the I2CONSET register. Writing 0 has no effect.
Each I2C Status register reflects the condition of the corresponding I2C interface. The I2C Status register is Read-Only.
The three least significant bits are always 0. Taken as a byte, the status register contentsrepresent a status code. There are 26 possible status codes. When the status code is 0xF8, there is no relevant information available and the SI bit is not set. All other 25 statuscodes correspond to defined I2C states. When any of these states entered, the SI bit will be set.
This register contains the data to be Transmitted or the data just received
These registers are readable and writable, and is only used when an I2C interface is set to slave mode. In master mode, this register has no effect. The LSB of I2ADR is the general call bit. When this bit is set, the general call address (0x00) is recognized
config the clock rate Set I2EN ---- Enables the i2c hardware DATA Transmission is started by setting start bit STA Start condition is transmitted, next SI bit will be set and Status register will be updated with 0x08h code. Reset SI bit and load the I2CDAT register with slave Address+ W .After transmitting again SI bit will be set ,read the Status register(0x18, 0x20, or 0x38) based on the code do appropriate action after Repeated start the I2C block is entered in to receiver mode by loading I2CDAT with SLA+R
CODE