
582
SAM G51 [DATASHEET]
11209C–ATARM–20-Dec-13
27.7.4 Multi-Master Mode
27.7.4.1
Definition
In multi-master mode, more than one master may handle the bus at the same time without data corruption by using
arbitration.
Arbitration starts as soon as two or more masters place information on the bus at the same time, and stops (arbitration is
lost) for the master that intends to send a logical one while the other master sends a logical zero.
As soon as arbitration is lost by a master, it stops sending data and listens to the bus in order to detect a STOP. When
the STOP is detected, the master that has lost arbitration may put its data on the bus by respecting arbitration.
27.7.4.2
Different Multi-Master Modes
Two multi-master modes may be distinguished:
1.
The TWI is considered as a master only and will never be addressed.
2.
The TWI may be either a master or a slave and may be addressed.
Note:
Arbitration in supported in both multi-master modes.
TWI as Master Only
In this mode, the TWI is considered as a master only (MSEN is always at one) and must be driven like a master with the
ARBLST (ARBitration Lost) flag in addition.
If arbitration is lost (ARBLST = 1), the user must reinitiate the data transfer.
If the user starts a transfer (ex.: DADR + START + W + Write in THR) and if the bus is busy, the TWI automatically waits
for a STOP condition on the bus to initiate the transfer (see
Figure 27-31).Note:
The state of the bus (busy or free) is not indicated in the user interface.
TWI as Master or Slave
The automatic reversal from master to slave is not supported in case of a lost arbitration.
Then, in the case where TWI may be either a master or a slave, the user must manage the pseudo multi-master mode
described in the steps below:
1.
Program the TWI in slave mode (SADR + MSDIS + SVEN) and perform a slave access (if TWI is addressed).
2.
If the TWI has to be set in master mode, wait until TXCOMP flag is at 1.
3.
Program the master mode (DADR + SVDIS + MSEN) and start the transfer (ex: START + Write in THR).
4.
As soon as the master mode is enabled, the TWI scans the bus in order to detect if it is busy or free. When the bus
is considered as free, the TWI initiates the transfer.
5.
As soon as the transfer is initiated and until a STOP condition is sent, the arbitration becomes relevant and the
user must monitor the ARBLST flag.
6.
If the arbitration is lost (ARBLST is set to 1), the user must program the TWI in slave mode in case the master that
won the arbitration wants to access the TWI.
7.
If the TWI has to be set in slave mode, wait until TXCOMP flag is at 1 and then program the slave mode.
Note:
In case the arbitration is lost and the TWI is addressed, the TWI will not acknowledge even if it is programmed in
slave mode as soon as ARBLST is set to 1. Then the master must repeat SADR.