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

The flowchart below gives an example of read and write operations in Multi-host mode.

Figure 45-30. Multi-host Flowchart