The I2C Protocol for Micro-controllers

The I2C Protocol for Micro-controllers

I2C : Inter-Integrated Circuits

It is very popular and very broadly used protocol for connecting peripherals to the machine (micro-controllers), this protocol is mainly implemented where we need more than one master and more than one client. There is a topology for each communication protocol like the simplest one among all these i.e. UART (universal Asynchronous Reception & Transmission) support point to point topology and SPI (Serial Peripheral Interface) supports one master and many clients topology. The I2C supports many masters and many clients topology.

  • Maximum 128 devices can be connected with a 7-bit address & 1024 devices can be connected with a 10-bit address.
  • The communication is achieved with only two lines or we can say with only two pins i.e. SDA and SCL . SDA (Serial Data) & SCL (Serial Clock)
  • Each device has a unique ID or Address so the master can choose with which device it will be communicating.
  • SDA (Serial Data) - this line carries the Data.
  • SCL (Serial Clock) - Serial Clock line generates a clock pulse which synchronizes the data transmission between the various devices on the I2C bus. This clock pulse is generated by the master.
  • Both the line are "Open drain" which means a pull-up resistance needs to be attached to keep them high because all the devices that work on I2C are active low. Commonly used values for resistors are 2K for higher data rates up to 400kbps and 10K for slower data rates up to 100kbps.

Working of the Protocol

  • First bit is the START bit.
  • Then a 8-bit sequence of device address is sent.
  • After that an ACKNOWLEDGE bit is transferred, after the first ACKNOWLEDGE bit the 8bit sequence is sent for the internal registers.
  • Then again an ACKNOWLEDGE bit is sent.
  • After that 8-bit sequence which actually contains the data.
  • Then again ACKNOWLEDGE bit & in the end a STOP bit is sent that confirms the proper data transmission.
No alt text provided for this image

The start condition occurs when the DATA line is low and the CLOCK pulse is high. After that the clock starts and data bit is transferred during each clock pulse. Device addressing starts from MSB (Most Significant Bit) to LSB (Least Significant Bit). The device address is composed of total 7-bits and the 8th bit is R/W bit it is used for the indication whether the master will read the data or write the data. If R/W bit is 0 then master will read and if it is 1 then master will write.

Then the Acknowledge bit is send, it is a indicator bit, which slave uses as an indication whether it successfully received the previous bit or not.

Now the SDA line is over to the slave for the acknowledge bit, if the slave pull-down the acknowledge bit that means the previous 8-bit address is received by the slave, if acknowledge bit is pulled high it means the slave doesn't receive the previous 8-bits.

Next is internal register addressing , internal registers are the location in slave's memory that contains various information and data.

Next is data transmission. Either from the master to slave or from slave to master depending upon the value of R/W bits. Then the data transmission will end with a stop condition. The stop condition arrives when the data line turns from low to high and the clock pulse is high.

ADVANTAGES :

  • More than one master can be used in an electronic device circuit.
  • only needs two wires for communication
  • I2C addressing is simple and it does not require any control signal like the SPI protocol.

DISADVANTAGES :

  • Increases the complexity of the circuit when the slaves and masters increases.
  • I2C interface is half duplex
  • Require software stack to control the protocol hence it needs some programming overheads on micro - controllers.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了