MultiMaster

There are I2C environments where multiple masters are driving the bus. In such a case, each device needs to be able to cooperate with the fact that another device may currently be transmitting — the bus is then busy and must be left alone.

This translates into two capabilities that every multimaster device must have.

Arbitration

If two devices start to communicate at the same time, the one writing more zeros to the bus wins the arbitration — and, thanks to clock synchronization, the slower clock prevails as well. The other device immediately discontinues any operation on the bus. Arbitration is performed bit by bit and is non-destructive: the winner’s message is not corrupted, and the loser is expected to detect the mismatch and report it. Many I2C peripherals offer a dedicated “arbitration lost” interrupt for this purpose. More on this mechanism can be found on the arbitration lost and clock synchronization and arbitration pages.

Bus busy detection

Each device must detect an ongoing bus communication and must not interrupt it. This is achieved by recognizing traffic on the bus and waiting for a stop condition to appear before starting to talk. If a stop condition never appears because a master hangs up, the bus stays blocked — see blocked bus for ways out of that situation.

Mixing single-master and multimaster devices

If you plan to use a multimaster device on a bus, it is essential that all masters on that bus are multimaster-capable. A single-master device is simply a device which does not understand the mechanisms described above. If a single-master and a multimaster are connected to the same bus, the single-master may well interrupt the multimaster, causing unpredictable results.

One side note for completeness: in High-speed mode no arbitration or clock synchronization takes place during the transfer itself. Competing High-speed masters arbitrate beforehand, at Fast-mode speed, while transmitting their master code — the High-speed transfer itself belongs exclusively to the winning master.