When connecting multiple devices to a microcontroller, the address and data lines of each device were conventionally connected individually. This would take up precious pins on the microcontroller, result in a lot of traces on the PCB, and require more components to connect everything together. This made these systems expensive to produce and susceptible to interference and noise.
To solve this problem, Philips developed Inter-IC bus, or I2C, in the 1980s. I2C is a low-bandwidth, short distance protocol for on board communications. All devices are connected through two wires: serial data (SDA) and serial clock (SCL).
Sample I2C Implementation
Figure 1: Sample I2C Implementation.
Regardless of how many slave units are attached to the I2C bus, there are only two signals connected to all of them. Consequently, there is additional overhead because an addressing mechanism is required for the master device to communicate with a specific slave device.
Because all communication takes place on only two wires, all devices must have a unique address to identify it on the bus. Slave devices have a predefined address, but the lower bits of the address can be assigned to allow for multiples of the same devices on the bus.
I2C has a master/slave protocol. The master initiates the communication. The sequence of events are:
- The Master device issues a start condition. This condition informs all the slave devices to listen on the serial data line for instructions.
- The Master device sends the address of the target slave device and a read/write flag.
- The Slave device with the matching address responds with an acknowledgement signal.
- Communcation proceeds between the Master and the Slave on the data bus. Both the master and slave can receive or transmit data depending on whether the communcation is a read or write. The transmitter sends 8-bits of data to the receiver which replies with a 1-bit acknowledgement.
- When the communication is complete, the master issues a stop condition indicating that everything is done.
I2C Communication Protocol
Figure 2: I2C Communication Protocol
Since there are only two wires, this protocol includes the extra overhead of an addressing mechanism and an acknowledgement mechanism
I2C has many important features worth mentioning. It supports multiple data speeds: standard (100 kbps), fast (400 kbps) and high speed (3.4 Mbps) communications.
Other features include:
- Built in collision detection
- 10-bit Addressing
- Multi-master support
- Data broadcast (general call).
For more information about other features, take a look at the references at the end of this article.
Since only two wires are required, I2C is well suited for boards with many devices connected on the bus. This helps reduce the cost and complexity of the circuit as additional devices are added to the system.
Due to the presence of only two wires, there is additional complexity in handling the overhead of addressing and acknowledgments. This can be inefficient in simple configurations and a direct-link interface such as SPI might be preferred.
- I2C-bus Specification and User Manual - NXP
- I2C (Inter-Integrated Circuit) Bus Technical Overview and Frequently Asked Questions - Embedded Systems Academy
- Introduction to I2C - Embedded.com
- I2C - Open Directory Project Listing