42.7.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 Multihost 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 42-28. User Sends Data While the Bus is Busy
Figure 42-29. Arbitration Cases

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

Figure 42-30. Multihost Flowchart