Embedded Basics Embedded MCU's Miscellaneous

I2C communication stands for inter-integrated circuits. I2C contains the best features of SPI & UART. It is a synchronous communication protocol. It transmits data serially. It is widely used in microcontrollers, IoT, sensors, displays, and EEPROMs, etc.

I2C can be single master multiple slaves and multiple master multiple or single slave. In this blog, we will get to know about I2C in depth.

Highlights of I2C

  • I2C works with 2 wires only for communication.
  1. SDA [Serial Data]: It is used by the Master and Slave for the transmission or receiving bits.
  2. SCL [Serial Clock]: It is used to carry clock signals.
  • I2C can communicate with 2 different methods.\"\"\"\"
  • Slave selection protocol uses a 7-bit slave address.
  • I2C doesn’t have any fixed length of data transfer.
  • Confirmation after transferring every byte.
  • Full-duplex.

How does I2C work?

\"Blog

Start Condition

To initiate the communication, the master keeps the SCL line high and pulls the SDA line low. If we have more than one master then the one who pulls the SDA line low first will send the data first and if the SDA line is already low then the other masters can not send the data.

Addressing

Master sends the same address to all the slaves. The slave then compares its own address with this address. If the address doesn’t match with the slave, the slave doesn’t do anything if it does match then the slave sends an acknowledge bit to the master.

Read/Write Bit

With the address, master sends the read/write bit to all the slaves where 0 indicates a write and 1 indicates a read. If the master wants to read data from the slave then it sends the read bit. If it wants to write then it sends a write bit.

ACK/NACK Bit

Each frame in a message is followed by an ack/nack bit. If an address frame was successfully received, an ACK bit is returned to the Master from the slaves.

THE DATA FRAME

When the acknowledge bit is received by the master, the master sends the data frame to the slave which is of 8 bits. After every data frame the slave sents an acknowledge bit to confirm that the data frame has been received successfully.

Stop Condition

To generate the stop condition master pulls the SCL from high to low and SDA line from low to high.

Applications of I2C

  • Communicating with multiple micro-controller.
  • Accessing low-speed DACs[digital to analog converter] and ADCs[analog and digital converter].
  • Accessing real-time clocks.
  • Reading hardware sensors.







Previous
Next

Kunal Gupta
Author: Kunal Gupta

Author

Kunal Gupta

Leave a comment

Stay Updated With Us

Error: Contact form not found.

      Blog