I2C – Everything you need to know

There is no need for a wordy introduction to I2C protocol. We all know it's main parts – 2 wires, multiple slaves, sometimes multiple masters, up to 5MHz of speed. Often so have we all implemented an I2C connection. Still, every now and then, there's that module that just won't work. This time, we will do an in-depth research about the I2C protocol, and try to cover as much ground as possible.

I2C – Everything you need to know

Overview of the design

I2C works with it's two wires, the SDA(data line) and SCL(clock line). Both these lines are open-drain, but are pulled-up with resistors. Usually there is one master and one or multiple slaves on the line, although there can be multiple masters, but we'll talk about that later. Both masters and slaves can transmit or receive data, therefore, a device can be in one of these four states: master transmit, master receive, slave transmit, slave receive.

Start from the start

The master initiates the communication by sending a START bit, this bit alerts all the slaves that some data is coming and they need to listen. After the start bit, 7 bits of a unique slave address is sent. Each slave has it's own slave address, this way, only one slave will respond to the data. The last sent bit is the read/write bit. If this bit is 0, it means that the master wishes to write data to a register of the slave, if this bit is 1, it means that the master wishes to read data from a register of a slave. Note that all the data is sent MSB first.

The start bit is generated by pulling the SDA line low, while the SCL is high. And the stop bit is indicated by releasing the SDA to high, along with the SCL being high. So, whenever a module wants to initialize communication, it has to assert SDA line. In our I2C library, which you can find in our compilers, the start bit is sent by calling the “I2C_Start();” function.

Read more: I2C – Everything you need to know

About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top