63.9.8 Sniffer Mode

The Client Sniffer mode of a TWI can be enabled to ease the analysis/debug of a TWI bus activity. The TWI bus to be analyzed can be monitored by one TWI host embedded in the product or by an I2C host outside the product.

In this mode, the TWI reports all (or part of) the TWI bus activity without impacting the TWI bus (no bus drive is performed). Depending on the MASK field value, only some specific transfers can be logged instead of the whole activity.

The peripheral TWIn can be configured to analyze the peripheral TWIn+1 (TWImax analyzes TWI0) in a full transparent mode via predefined internal connections between TWI instances (n is the index of the TWI instance).

The predefined internal connections provide the capability to use the TWD and TWCK pins for alternate functions while the TWI peripheral is configured in Sniffer Client mode and the selected TWI bus to analyze is carried on these internal links.

The following fields must be programmed before entering Client mode:

  1. FLEX_TWI_SMR.SADR: Use the client device address to indicate which frame(s) to log.
  2. FLEX_TWI_SMR.MASK: Indicate which SADR bits should be masked and thus which transfers should be logged (set to 0x7F to log the whole TWI bus activity; all SADR bits are masked in this case). General Call accesses will always match.
  3. FLEX_TWI_SMR.BSEL: Select the TWI bus to analyze (see figure Sniffer Mode Application Overview).
  4. FLEX_TWI_SMR.SNIFF: Set to ‘1’ to enable Client Sniffer mode.
  5. FLEX_TWI_CR.MSDIS: Disable Host mode.
  6. FLEX_TWI_CR.SVEN: Enable Client mode.

As the device receives the clock, values written in FLEX_TWI_CWGR are not relevant.

Once configured in Client Sniffer mode, the FLEX_TWI_SR.RXRDY bit indicates when a transfer has been logged in FLEX_TWI_RHR. An interrupt can be generated if configured. The FLEX_TWI_SR.OVRE flag indicates if an overrun error occurred if the application is not fast enough to read FLEX_TWI_RHR.

In Client Sniffer mode, FLEX_TWI_RHR logs data as follows:

  • The RXDATA field reports the sniffed 8-bit data field.
  • The SSTATE field indicates if a START condition has been detected before the 8-bit data field.
  • The PSTATE field indicates if a STOP condition has been detected after the previously sniffed 8-bit data field.
  • The ASTATE field indicates which acknowledge condition has been detected after the previously sniffed 8-bit data field.
Figure 63-136. Sniffer Mode Application Overview
Figure 63-137. Client Sniffer Mode Log