28.6.13 Multi-Master Communication, Bus Collision and Bus Arbitration
Multi-Master mode support is achieved by bus arbitration. When the
master outputs address/data bits onto the SDA pin, arbitration takes place when the master
outputs a ‘1
’ on SDA, by letting SDA float high and
another master asserts a ‘0
’. When the SCL pin floats high, data should be
stable. If the expected data on SDA is a ‘1
’ and
the data sampled on the SDA pin is ‘0
’, then a bus collision has taken
place. The master will set the Bus Collision Interrupt Flag, BCLxIF and reset the I2C port to its Idle state (Figure 28-32).
If a transmit was in progress when the bus collision occurred, the transmission is halted, the BF flag is cleared, the SDA and SCL lines are deasserted and the SSPxBUF can be written to. When the user services the bus collision Interrupt Service Routine and if the I2C bus is free, the user can resume communication by asserting a Start condition.
If a Start, Repeated Start, Stop or Acknowledge condition was in progress when the bus collision occurred, the condition is aborted, the SDA and SCL lines are deasserted and the respective control bits in the SSPxCON2 register are cleared. When the user services the bus collision Interrupt Service Routine and if the I2C bus is free, the user can resume communication by asserting a Start condition.
The master will continue to monitor the SDA and SCL pins. If a Stop condition occurs, the SSPxIF bit will be set.
A write to the SSPxBUF will start the transmission of data at the first data bit, regardless of where the transmitter left off when the bus collision occurred.
In Multi-Master mode, the interrupt generation on the detection of Start and Stop conditions allows the determination of when the bus is free. Control of the I2C bus can be taken when the P bit is set, or the bus is Idle and the S and P bits are cleared.