I2C — An Integral Advancement In Serial Communication

Kshitij Vaze
7 min readNov 19, 2023

--

Hello, everyone! Welcome back to my blog. If you are new here, I am Kshitij Vaze, a 20-year-old student pursuing a Bachelor’s degree in Electronics and Telecommunication engineering. I also work as an embedded systems engineer at my college’s robotics research and development team, Team Automatons.

In continuation with our discussion about serial communication protocols used in embedded systems, today, we’ll take a look at Inter-Integrated Circuit communication, commonly called I2C Communication. Stay tuned for an informative and interesting read!

1. Origin

Back during the 1980s, Phillips Semiconductors (now known as NXP semiconductors) was looking for an alternative way of serial communication between various components in the circuitry of consumer electronics. Back then, SPI was all the rage, being the fastest and the most popular method of passing around data and information, by far. The problem, however, lies within the ever-rising noise levels in electronics.

It is quite intuitive that as electronics become faster and better, the circuits used become more and more complex to support the boost of power that the application demands. This led to a rise in noise levels, and a general desire to de-clutter the electronic circuits to manage the available space much more efficiently.

The solution that the brilliant engineers at Phillips came up with is what we know today as the I2C protocol. They came up with a novel 2 Wire Interface, that was originally intended to provide a bus-like interconnect interface for the internal electronics of its television sets. The solution was widely regarded for its simplicity and versatility. Throughout the late 80s to early 90s, this protocol went mainstream throughout the electronics industry, finding usage in microelectronic components, sensors, consumer electronics, and motherboards, cementing itself as an important and reliable protocol of serial communication. Let’s dive deep and understand the protocol in an intuitive fashion

2. Features and Working

All you need to implement I2C communication is a twisted wire couple, where one wire acts as the Serial Data line (SDA) and the other acts as the Serial Clock line (SCL). As per the rules, the SDA and SCL lines are connected to a pull-up resistor, which maintains the idle state of the data line of the bus at a “LOGIC HIGH” level.

According to the specification, we can connect a maximum of 128 devices on a single I2C Bus, as exceeding this number violates the tolerable bus capacitance. Every device has a unique address, which is 7 bits long (2⁷ = 128 addresses possible). The protocol is half-duplex in nature, meaning that at a time, only 1 controller can transmit messages over the bus. It follows a master-slave style of device connection, while also supporting multi-master modes.

# SDA and SCL lines

These are bidirectional signals, connected to a positive voltage supply. As mentioned above, both of these lines are pulled up using resistors, ensuring that both lines are in a HIGH Idle state. The SDA line is responsible for the transmission of the data frame, which consists of 7 bits for the device address, 1 bit for the data direction specifier, and an 8-bit long data packet.

The SCL is responsible for delivering the clock signal to every device that is connected to the I2C bus, ensuring synchronization of operation for every device. The Data on the SDA line can change only when the SCL line is in a low state and must be stable during the high state of the SCL

# Start/Stop conditions

Before the transmission of every byte of data, we have to generate a start condition on the data line, by forcing a HIGH-TO-LOW transition on the SDA line while the SCL line is in a HIGH state. This ensures that the receiving slave devices are ready to receive the incoming transmission and acknowledge it.

Once the transmission is over, the sender generates a stop condition on the bus by forcing a LOW-TO-HIGH transition on the SDA line while the SCL line is in a HIGH state.

# Byte Format

As per specification, every byte has to be 8 bits long, followed by an ACK signal. The Data is sent in the MSB first format, with no limit for the number of bytes per transfer.

# Acknowledge and Not Acknowledge Bits

The ninth signal on the SDA line after the 8 bits of data is the ACK or the NACK bit. The purpose of this signal is to confirm the transmission of the data over the bus. For an ACK signal, the sending device releases the SDA Line, and the receiver pulls the line LOW, maintaining the LOW level during the 9th pulse of the SCL line.

If the SDA is HIGH during the 9th pulse, then it is considered a NACK signal. This may lead to the generation of a stop signal or a repeated start signal, which would trigger retransmission of the unsuccessfully sent signal. The causes of a NACK signal are as follows -

  1. No receiver is present on the bus with the transmitted address so there is no device to respond with an ack bit.
  2. The receiver is unable to receive or transmit because it is performing some real-time function and is not ready to start communication with the controller.
  3. During the transfer, the receiver gets data or commands that it does not understand.
  4. During the transfer, the receiver cannot receive any more data bytes.
  5. A controller-receiver must signal the end of the transfer to the target transmitter.

# Clock Synchronization and Arbitration

These are two concepts used in the case of multi-master configuration. When there are two or more than two controllers trying to send a message and take control of the clock in an I2C bus, we have a method to decide who eventually controls the bus

We utilize the wired-AND connection of the controllers to the SCL line. Essentially, a controller can hold the SCL line in a LOW state until all other controllers are ready to match their clock signals to the low level, releasing the SCL line immediately after the matching process is complete. This ensures that all controllers generate the SCL at the same speed, which stops unwanted disruptions on the bus clock.

Arbitration is a process that ensures that no message conflict arises on the bus. For every HIGH state for the SCL during the transmission on the SDA, every controller checks the SDA line to compare the existing value to what it has sent. If it tries to send a high, but detects a low on the SDA line due to a transmission conducted by another controller, it turns off its SDA drive, knowing that it has lost the arbitration. The other controller completes its transmission, after which the first controller re-sends its data.

# Clock Stretching

This feature gives the slave devices the power to pause the bus if it cannot complete the reception or transmission of data within the time period of the SCL. This allows slower devices to successfully interface with the I2C bus.

Here is what a complete data transfer packet looks like in I2C Communication -

3. Applications

Here is a list of the major commercial applications of I2C -

  1. Embedded Systems: I2C is frequently used for communication between microcontrollers and other peripheral devices such as sensors, EEPROMs (Electrically Erasable Programmable Read-Only Memory), and real-time clocks.
  2. Consumer Electronics: I2C is used for communication between different components within a television or audio system, such as tuners, audio processors, and display controllers.
  3. Computers and Peripherals: I2C is employed on computer motherboards for communication between the BIOS (Basic Input/Output System) and various peripheral devices, including temperature sensors, voltage regulators, and fan controllers.
  4. Sensor Networks: Many environmental sensors, such as temperature sensors, humidity sensors, and pressure sensors, utilize I2C for communication with microcontrollers or other host devices. It is also commonly used in IMUs that combine accelerometers and gyroscopes for applications like motion sensing and orientation tracking.
  5. Communication with Displays: I2C is often used to communicate with small displays, such as OLED (Organic Light-Emitting Diode) and LCD (Liquid Crystal Display) screens, in applications like wearables and small electronic devices.
  6. Networking and Communication Devices: I2C can be used for communication between components in networking devices, such as Ethernet switches. Some audio codecs also use I2C for control and configuration settings.
  7. Industrial Automation: I2C can be used in industrial automation for communication between control systems, sensors, and actuators.
  8. IoT (Internet of Things) Devices: I2C is utilized in various smart home devices, including sensors, actuators, and controllers, and is suitable for connecting sensors and peripherals in IoT edge devices.

That’s all for this blog. If you have made it this far, I am grateful for your time. As always, my inbox, DMs, and comments are always open for doubts, discussion, and criticism. See y’all next weekend!

--

--

Kshitij Vaze

Engineering Student, upcoming embedded solutions architect