I2C

I2C or IIC stands for “Inter-Integrated Circuit,” and was originally intended as a way to communicate from one IC to another, usually on the same PCB. I2C is a bi-directional serial bus that was originally created by Philips (now NXP).

Detailed Definition

In a typical I2C application, there will be one master, and one or more slaves. The specification allows for multiple masters, but this is not common in the field.

I2C has two signals:

  • SCL: Serial CLock
  • SDA: Serial Data

The I2C transfer includes an address, so multiple slaves can exist on the same I2C bus.

Typically, both the master and slave are implemented in hardware. The I2C master can be implemented in software quite easily, but it can be rather difficult to meet the timing requirements of I2C in a software slave implementation. As micro controllers continue to get faster, writing an I2C software slave will become easier.

The I2C standard is pretty well defined, so there is not a huge amount of variation in I2C as it is implemented on LCD and OLED controllers.

Signal Example for I2C - www.crystalfontz.com

Some caveats when using I2C:

  1. Your I2C bus needs to have one pull-up resistor on the SCL line and one pull-up resistor on the SDA line. Typically 5.6K Ohms works well for most applications.
  2. Every slave on the I2C bus must have a unique address. Typically a system only has one display, but you might share the bus with some other I2C component–perhaps a touch screen controller or EEPROM. Usually each chip that has an I2C interface has one or more possible slave addresses that can be set by pins. There are some devices that have a fixed I2C address, if you want more than one of these on the bus you must use a multiplexer to connect and disconnect them.
  3. The I2C address is 7 bits, but an 8th R/W (Read/Write) bit is always appended to the address. Some manufacturers will specify their device’s address as the number without the R/W bit (example: 40 is the specified 7-bit address, 80 is used to write and 81 is used to read). Others would specify this same address as 80. So if you are having trouble talking to your device look closely at the way the manufacturer specifies the address.

Additional I2C Facts

An interesting thing about I2C that you might not be aware of is that a slow slave device can stretch every bit by holding the clock low, and additionally stretch the entire transaction. Most modern slave I2C devices are fast enough that they do not need to do this clock stretching.

One limitation of I2C is that the slaves do not have a way of getting the master’s attention. So if the slave is a system input, the master must poll it to check for new activity.

Questions?

If you have any questions, please contact our knowledgeable and friendly support staff by email, phone, or chat.

Related Entries