W have already discussed UART and SPI before. Next, up is I2C communication often pronounced as I-squared C or I-2-C communication. This is a protocol designed by Phillips in ’90s for communicating between devices inside the TV set. I2C simple, short distance protocol and most of the devices are capable of operating at 400 Kbps. In this article let’s have an idea about I2c and in the next one, we will implement it in AVR controller.
I2C Communication Features
I2C communication has a property from UART and SPI. Like UART, it uses Two Wire Interface. Like SPI, this communication protocol uses Master-slave Protocol. Multiple slaves can be connected to one master. Like SPI, I2C is synchronous, it means the data communication between master and slave is synchronized. Some of the features of I2C communication that makes this protocol so popular are:
- Only two bus lines are required; a serial data line (SDA) and a serial clock line (SCL).
- The transfer speed is up to 100 Kbps in standard mode, up to 400Kbps in Fast-Mode, up to 1Mbps in Fast-mode plus, or up to 3.4 Mbps in the High-speed Mode. Unidirectional data transfer is up to 5 Mbps in Ultra-Fast-mode
- On-chip filtering rejects spikes on the bus data line to preserve data integrity.
I2C Communication Protocol Working
Communication begins with the “Start” condition and “Stop” condition. These conditions are always generated by the Master. A HIGH to LOW transition on the SDA line, while SCL is HIGH, defines a START condition whereas a LOW to HIGH transition on the SDA line while SCL is HIGH defines a STOP condition. The bus is considered to be busy after the start condition and it becomes free after a certain time after a stop condition.
Each byte put on the SDA line must be 8 bits long. If a slave has to perform another operation after receiving the data, it can put the Master in “wait” state. Data transmission continues after slave is ready. The acknowledge takes place after every byte. The acknowledge bit allows the receiver to signal the transmitter that the byte was successfully received and another byte may be sent.
It doesn’t have a slave select line and therefore it needs another mechanism to select the slave. It is done by addressing. So, every slave has been assigned to its own address. The master sends the address it wants to communicate. Each slave compares its own address with the address it receives. If the address matches, it sends an ACK to the controller and the communication start like the explained earlier. It does nothing if the address doesn’t match.
Ways of connection of I2C
- Single Master with single slave
- Single master with multiple slaves
- Multiple masters with multiple slaves
Advantage and Disadvantages of I2C
- Flexibility– because it supports multiple masters, multiple slave communication which gives you a lot of flexibility to your design
- Simplicity – I2C protocol doesn’t complicate the design. It requires only two bidirectional signal lines to establish communication among multiple devices. Further, the pin count is low as well.
- Better error handling mechanism – To improve the error detection and correction mechanism, the I2C protocol relies on ACK feature, which is a robust error correction feature.
- Conflicts – Due to chip addressing, there’s always a possibility of an address conflict.
- Requires more space – Now, as an embedded system engineer, you know how valuable PCB real estate is. So, it isn’t such a positive attribute that the I2C protocol requires so much space for its pull-up resistors.
I think that’s it for this article. If you have any problem or query, please do ask in the comment box below. Do check out other articles as well.