I2C Communication Interface
Efficient communication between components is crucial in embedded systems. Among the available serial protocols, I2C (Inter-Integrated Circuit) is a popular choice due to its simplicity, low power consumption, and minimal wiring requirements.
What Is I2C?
I2C (pronounced “I-squared-C” or “I-two-C”) is a serial, synchronous communication protocol that allows multiple devices to communicate over a two-wire bus:
- SDA (Serial Data Line)
- SCL (Serial Clock Line)
These open-drain lines are pulled high with resistors, allowing bi-directional communication over short distances. I2C supports multi-master and multi-slave configurations and is designed primarily for communication between integrated circuits on a PCB.
Key Features of I2C
- Serial, synchronous protocol
- Two-wire interface (SDA and SCL)
- Multi-master, multi-slave support
- Half-duplex communication
- Clock stretching: Slaves can hold the clock low to delay communication
- Arbitration: Resolves bus access conflicts between masters
- 7-bit or 10-bit addressing
- Speed modes:
- Standard mode: 100 kbps
- Fast mode: 400 kbps
- Fast Mode Plus: 1 Mbps
- High-Speed mode: 3.4 Mbps
How I2C Works
I2C devices operate as either:
- Master (Controller): Initiates and manages communication
- Slave (Peripheral): Responds to the master
Communication Process
- Idle State
Both SDA and SCL lines are high when the bus is idle. - Start Condition
The master pulls SDA low while SCL is high to initiate communication. - Address Frame
The master sends:- A 7-bit address (or 10-bit in extended format)
- A Read/Write bit (0 for write, 1 for read)
- Acknowledgment (ACK)
The addressed slave pulls SDA low to acknowledge the master. - Data Transfer
- Write: Master sends data, slave acknowledges
- Read: Slave sends data, master acknowledges each byte (except final, where it sends NACK)
- Stop Condition
Master releases SDA from low to high while SCL is high, ending communication. - Repeated Start
A repeated start condition can be issued to change data direction or begin a new transfer without releasing the bus.
Additional Capabilities
Addressing Multiple Devices
Each slave has a unique address. Only the addressed device responds; others ignore the transmission.
Clock Stretching
Slaves can delay communication by holding the SCL line low until ready.
Bus Arbitration (Multi-Master)
If two masters initiate communication simultaneously:
- Each checks the SDA line after sending a bit.
- If a master detects a mismatch (writes 0, reads 1), it withdraws, conceding control.
Pros and Cons
Advantages
- Requires only two wires regardless of device count
- Supports multiple masters and slaves
- Low power consumption
- Integrated addressing
- Widely supported in microcontrollers and peripherals
- Multiple speed modes for flexibility
Disadvantages
- Slower than protocols like SPI
- Designed for short-range communication
- No error checking
- Single-ended signaling is more susceptible to noise
- Complexity increases with large device networks
I2C vs. Other Protocols
| Protocol | Wires | Speed | Complexity | Power | Typical Use Cases |
|---|---|---|---|---|---|
| I2C | 2 | Slow | Medium | Low | Sensors, displays, EEPROMs |
| SPI | 4 | Fast | Medium | Medium | Flash memory, ADCs, DACs |
| UART | 2 | Slow | Low | Low | Long-distance, simple links |
| CAN | 2 | Fast | Medium | Medium | Automotive, industrial |
| RS-232 | 3 | Slow | Medium | Medium | PCs, modems, serial ports |
I2C vs. SPI
- I2C: Two wires, built-in addressing, multi-master capable
- SPI: Faster, full-duplex, requires more wires (MOSI, MISO, SCLK, SS)
I2C vs. UART
- I2C: Multi-device, synchronous with clock line
- UART: Point-to-point, asynchronous (no clock)
I2C vs. CAN
- I2C: No error checking, short range
- CAN: Robust error handling, ideal for noisy environments
I2C vs. RS-232
- I2C: Supports multiple devices, limited to short distances
- RS-232: Two devices only, better for long distances
Conclusion
I2C is a versatile, space-saving communication protocol ideal for short-distance, low-speed applications in embedded systems. Its ability to connect multiple devices with minimal wiring makes it especially attractive for sensor networks, display modules, and peripheral management. While not the fastest or most robust option, its simplicity and broad support make it a go-to solution in many electronics designs.