Getting Started with I2C: What is Bus Arbitration

1. What is I2C Protocol?

I2C (Inter-Integrated Circuit) is a widely used communication protocol that connects microcontrollers and other integrated circuits in embedded systems. Its primary purpose is to enable communication between different components within a system. It operates on a synchronous serial communication mechanism, using a single clock line and a data line to transfer data between devices.

2. What is I2C protocol bus arbitration?

One of the key features of the I2C protocol is arbitration, which allows multiple devices to communicate on the same bus. In I2C communication, arbitration is used to resolve conflicts that occur when two or more devices attempt to transmit data at the same time. The arbitration mechanism ensures that only one device has control of the bus at any given time, and that data is transmitted without any errors. 

When two or more devices try to communicate with each other on the I2C bus at the same time, an arbitration process occurs to determine which device has priority to transmit data on the bus. This is known as I2C bus arbitration.

The arbitration process in I2C is based on a wired-AND logic system. In this system, each device on the bus can pull the bus lines low (logic 0), but cannot pull them high (logic 1). Therefore, if two or more devices try to transmit data at the same time, they will both try to pull the bus lines low. The device that pulls the bus lines low first will win the arbitration and will be able to transmit its data on the bus.

To understand I2C bus arbitration, let's consider an example where two I2C Master devices, Master 0 and Master 1, are connected to the same I2C bus (SDA and SCL). Both masters are attempting to transmit data on the bus simultaneously with the goal of sending the data frame to a same sensor acting as an I2C Slave.

At the beginning of communication, both Master '0' and Master '1' will inspect the bus to determine if it is free. If the bus is available, both masters will commence transmitting their data simultaneously. Nonetheless, if both masters attempt to lower the bus lines concurrently, an arbitration procedure will take place, which is illustrated in the figure below.

During this arbitration process, both masters will persist in lowering the bus lines until one of them successfully pulls them down first, as seen in the figure above. At the outset, both Master 0 and 1 were transmitting identical data. However, when Master '0' transmitted data 0x2A while Master '1' sent 0x2F, Master '0' emerged as the winner of the arbitration by pulling down the SDA line first as 0x2A is 0x00101010. Therefore, Master '0' will proceed to transmit its data on the bus. Meanwhile, Master '1' recognized that the bus was no longer free and hence backed off, waiting for the next opportunity to transmit its data.

In summary, I2C bus arbitration is a process used to determine which device has priority to transmit data on the bus when multiple devices try to transmit data at the same time. The device that pulls the bus lines low first wins the arbitration and is able to transmit its data on the bus. The other device backs off and waits for the next opportunity to transmit its data.