I have looked at I2C and caveats with multiple masters and a question concerning the multi-master compatibility of I2C switches.
The PCA9544 datasheet states on p. 13 that:
When a channel is selected, the channel becomes active after a stop condition has been placed on the I2C bus.
This ensures that all SCn/SDn lines are in a high state when the channel is made active,so that no false conditions are generated at the time of connection.
This makes sense, however it also states:
"A stop condition always must occur right after the acknowledge cycle."
The intended sequence seems to be
(START) (Slave Addr) (Write) (ACK) (New channel config) (ACK) (STOP)
I tried to change the active channel of the switch, but followed by a repeated start instead e.g.
(START) (Slave Addr) (Write) (ACK) (New channel config) (ACK) (Repeated Start) (More transactions to other devices) (STOP)
It seems like the switch ignores the new channel configuration and keeps its previous setting. The transactions following the repeated start are therefore send over the wrong bus.
Using separate transmissions with a stop seems to be no problem in a single master configuration.
With multiple masters however, the repeated start is the only method to ensure that the transfer is carried out as intended.
A small example with
- master 1 wants to read device X on switch channel 1
- master 2 wants to read device Y on switch channel 2
An unwanted outcome of this might be
- master 1 reconfigures the switch to connect channel 1, transmission ends with Stop
- master 2 takes over the bus and reconfigures the switch to connect channel 2 and disconnect channel 1
- master 1 reads device X. If the address is occupied on channel 2 as well, master 1 doesn't even realize its the wrong device.
- master 2 reads the correct device Y without error.
As far as i understood it, the repeated start is the only method to avoid (rare) situations like this.
Without it, the switches are not 100% safe to use on a bus with multiple masters.
The switch addresses contain the maximum of 1's, so access to other devices should most of the time win the arbitration process.
I doubt that there isn't a device within the same address range of 0x70-0x77.
Other devices aside, what about cascading multiple switches to interface 4 x 4 branches instead of 4?
My questions:
How to use (cascaded) I2C switches on a multi-master bus?
Is it somehow possible to use the switches with a repeated start or am i missing something and this is not necessary?
Why is an immediate stop mandatory and the repeated start not usable?