37.4.1.3.2 Client Reception (7-Bit Addressing Mode)
The following section describes the sequence of events that occur when the module is receiving data in 7-bit Addressing mode:
- The host issues a Start condition. Once the Start is detected, client hardware sets the Start Condition Interrupt Flag (SCIF) bit. If the Start Condition Interrupt Enable (SCIE) bit is also set, the generic I2CxIF bit is also set.
- The host transmits the 7-bit client address with the R/W bit clear, indicating that it intends to write data to the client.
- The received address is compared to
the values in the I2CxADR registers. If the client is configured in 7-bit Addressing
mode (no masking), the received address is independently compared to each of the
I2CxADR0/1/2/3 registers. In 7-bit Addressing with Masking mode, the received
address is compared to the masked value of I2CxADR0
and I2CxADR2.
If an address match occurs:
- The Client Mode Active (SMA) bit is set by module hardware.
- The R/W bit value is copied to the Read Information (R) bit by module hardware.
- The Data (D) bit is cleared (D =
0
) by hardware, indicating the last received byte was an address. - The Address Interrupt Flag
(ADRIF) bit is set (ADRIF =
1
). If the Address Interrupt and Hold Enable (ADRIE) bit is set (ADRIE =1
) and the Clock Stretching Disable (CSD) bit is clear (CSD =0
), hardware sets the Client Clock Stretching (CSTR) bit and the generic I2CxIF bit. This allows time for the client to read either I2CxADB0 or I2CxRXB and selectively ACK/NACK based on the received address. When the client has finished processing the address, software must clear CSTR to resume operation. - The matching received address
is loaded into either the I2CxADB0 register or into the I2CxRXB register as determined by the Address Buffer Disable
(ABD) bit. When ABD is clear (ABD =
0
), the matching address is copied to I2CxADB0. When ABD is set (ABD =1
), the matching address is copied to I2CxRXB, which also sets the Receive Buffer Full Status (RXBF) bit and the I2C Receive Interrupt Flag (I2CxRXIF) bit. I2CxRXIF is a read-only bit and must be cleared by either reading I2CxRXB or by setting the Clear Buffer (CLRBF) bit (CLRBF =1
).
If no address match occurs, the module remains Idle.
- The host device transmits the 9th
clock pulse, and client hardware transfers the value of the ACKDT bit onto the SDA line. If there are pending errors,
such as a receive overflow (RXO =
1
), client hardware automatically generates a NACK condition. NACKIF is set, and the module goes Idle. - Upon the 9th falling SCL edge, the
Acknowledge Status Time Interrupt Flag (ACKTIF) bit is set. If the Acknowledge Interrupt and Hold
Enable (ACKTIE) bit is also set, the generic I2CxIF is set, and if
client hardware generated an ACK, the CSTR bit is also set and the clock is stretched (when CSD =
0
). If a NACK was generated, the CSTR bit remains unchanged. Once complete, software must clear CSTR and ACKTIF to release the clock and continue operation. - If client hardware generated a NACK, host hardware generates a Stop condition, the Stop Condition Interrupt Flag (PCIF) bit is set when client hardware detects the Stop condition, and the client goes Idle. If an ACK was generated, host hardware transmits the first seven bits of the 8-bit data byte.
- If data remains in I2CxRXB
(RXBF =
1
and I2CxRXIF =1
) when the first seven bits of the new byte are received by the shift register, CSTR is set, and if CSD is clear, the clock is stretched after the 7th falling edge of SCL. This allows time for the client to read I2CxRXB, which clears RXBF and I2CxRXIF, and prevents a receive buffer overflow. Once RXBF and I2CxRXIF are cleared, hardware releases SCL. - Host hardware transmits the 8th bit
of the current data byte into the client receive shift register. Client hardware
then transfers the complete byte into I2CxRXB on the 8th
falling edge of SCL and sets the following bits:I2CxCNT is decremented by one. If the Data Write Interrupt and Hold Enable (WRIE) is set (WRIE =
1
), hardware sets CSTR (when CSD =0
) and stretches the clock, allowing time for client software to read I2CxRXB and determine the state of the ACKDT bit that is transmitted back to the host. Once the client determines the Acknowledgment response, software clears CSTR to allow further communication. - Host hardware transmits the 9th clock
pulse. If there are pending errors, such as receive buffer overflow, client hardware
automatically generates a NACK condition, sets NACKIF, and the module goes Idle. If I2CxCNT is
nonzero (I2CxCNT !=
0
), client hardware transmits the value of ACKDT as the acknowledgment response to the host. It is up to software to configure ACKDT appropriately. In most cases, the ACKDT bit must be clear (ACKDT =0
) so that the host receives an ACK response (logic low level on SDA during the 9th clock pulse).If I2CxCNT is zero (I2CxCNT =0
), client hardware transmits the value of the Acknowledge End of Count (ACKCNT) bit as the Acknowledgement response, rather than the value of ACKDT. It is up to software to configure ACKCNT appropriately. In most cases, ACKCNT must be set (ACKCNT =1
), which represents a NACK condition. When host hardware detects a NACK on the bus, it will generate a Stop condition. If ACKCNT is clear (ACKCNT =0
), an ACK will be issued, and host hardware will not issue a Stop condition. - Upon the 9th falling edge of SCL, the ACKTIF bit is set. If ACKTIE is also set, the generic I2CxIF is set, and if CSD is clear, client hardware sets CSTR and stretches the clock. This allows time for software to read I2CxRXB. Once complete, software must clear both CSTR and ACKTIF to release the clock and continue communication.
- Repeat steps 6-10 until the host has
transmitted all the data (I2CxCNT =
0
) or until the host issues a Stop or Restart condition.