TWIHS 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 TWIHS may be either a master or a slave, the user must manage the pseudo Multimaster mode described in the steps below:

  1. 1.Program the TWIHS in Slave mode (SADR + MSDIS + SVEN) and perform a slave access (if TWIHS is addressed).
  2. 2.If the TWIHS has to be set in Master mode, wait until TXCOMP flag is at 1.
  3. 3.Program the Master mode (DADR + SVDIS + MSEN) and start the transfer (ex: START + Write in THR).
  4. 4.As soon as the Master mode is enabled, the TWIHS scans the bus in order to detect if it is busy or free. When the bus is considered free, the TWIHS initiates the transfer.
  5. 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. 6.If the arbitration is lost (ARBLST is set to 1), the user must program the TWIHS in Slave mode in case the master that won the arbitration needs to access the TWIHS.
  7. 7.If the TWIHS has to be set in Slave mode, wait until the TXCOMP flag is at 1 and then program the Slave mode.
Note: If the arbitration is lost and the TWIHS is addressed, the TWIHS does not acknowledge, even if it is programmed in Slave mode as soon as ARBLST is set to 1. Then the master must repeat SADR.
Figure 1. User Sends Data While the Bus is Busy
Figure 2. Arbitration Cases

The flowchart below gives an example of read and write operations in Multimaster mode.

Figure 3. Multimaster Flowchart