Today we are going to discuss about I2C communication. I2C is a Synchronus Tx and Rx communication. I2C stands for Inter Integrated Circuits. I2C is also known as TWI or Twin Wire Interface because it only requires two wires to communicate between different devices. I2C bus consists of SCL (Clock) and SDA (Data). In order to communicate to a slave, Master first sends the address byte along the data line. All slaves connected to the bus will match their addresses with the address sent by master. In case of a match, the respective slave sends the ACK (acknowledgement) to the master and communication begins.
As you might have noticed above that master is pulling SDA and SCL high and low. To ensure this operation a PULL-UP register (typically 4k7) must be connected to SDA and SCL.
First start (S) is transmitted by microcontroller. Next uc sends address of the device, on receiving address, device sends the A (ack) signal back to uc.
Next uc sends data bits (04, 00, 24, 20). After receiving each data byte, device sends the A(ack) to uc.
At last uc sends P( stop) signal to indicate the end of communication.
I2C is very important part of embedded systems. As the address of slave is 7/10 bit long, we can connect 256/1024 slaves with a single master. This means we can control 256 (7 bit address) devices with only two pins of our microcontroller. This reduces the need for using excessive wiring and also we have all other pins available for other purposes.
I2C is used in number of communications devices. For eg- RTC (ds1307), Lcd, OLEDs, Accelerometer (ADXL345), temperature sensors, pressure sensors, etc.
I will cover the coding part in upcoming tutorials.