47.9.4.2.2 TWI as Host or Client

The automatic reversal from host to client is not supported in case of a lost arbitration.

Then, in the case where TWI may be either a host or a client, the user must manage the pseudo Multi-Host mode described in the steps below:

  1. Program the TWI in Client mode (SADR + MSDIS + SVEN) and perform a client access (if TWI is addressed).
  2. If the TWI has to be set to Host mode, wait until TXCOMP flag is at 1.
  3. Program Host mode (DADR + SVDIS + MSEN) and start the transfer (ex: START + Write in THR).
  4. As soon as Host 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 = 1), the user must program the TWI in Client mode in case the host that won the arbitration needs to access the TWI.
  7. If the TWI has to be set to Client mode, wait until TXCOMP flag is at 1 and then program Client mode.
    Note: In case the arbitration is lost and the TWI is addressed, the TWI will not acknowledge even if it is programmed in Client mode as soon as ARBLST = 1. Then the host must repeat SADR.
    Figure 47-110. User Sends Data While the Bus is Busy
    Figure 47-111. Arbitration Cases

The flowchart shown in the following figure gives an example of read and write operations in Multi-Host mode.

Figure 47-112. Multi-Host Mode