The following section describes the sequence of events when using the I2C in Slave mode reception.
If the slave 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 mode with masking, the received address is masked with the value of I2CxADR1 and I2CxADR3, and then compared to the value of I2CxADR0 and I2CxADR2.
If a
match occurs, the Slave Mode Active (SMA) bit is set, the
R/W bit information (bit ‘0’ of
the matching address) is transferred to the Read Information (R) bit of the
I2CxSTAT0 register, the Data (D) bit of the I2CxSTAT0 register is cleared, and
the Address Interrupt Flag (ADRIF) bit is set. If the ABD is cleared, the
matching address is copied into the I2CxADB0 register. If ABD is set, the
matching address is copied into the receive buffer, I2CxRXB, setting the Receive
Buffer Full (RXBF) and I2C Receive Interrupt Flag (I2CxRXIF) bits. I2CRXIF is a
read-only bit, and must be cleared by setting the Clear Buffer (CLRBF) bit or
reading I2CxRXB.
If no address match occurs, the module stays idle.
0, the Byte Count
Interrupt Flag (CNTIF) is set.0, the slave hardware sets CSTR. This allows time for the slave
to read the address from either I2CxADB0 or I2CxRXB. Once complete, the slave
software clears CSTR to release the clock, and clears ACKTIF to continue
communication.If the slave issued an ACK, the master transmits the first 7 bits of the 8-bit data byte.
1 and I2CRXIF = 1) when
the first seven bits of the new byte are received into the Shift register, the CSTR
bit is set, and the clock is stretched after the 7th falling edge of SCL. This
allows the slave software to read I2CxRXB, which clears the RXBF and I2CxRXIF bits,
and prevents a receive buffer overflow. Once the RXBF bit is cleared, the software
clears CSTR, which releases SCL.1), the hardware sets CSTR, allowing time for slave software to
read I2CxRXB and decide the state of the ACKDT bit before clearing CSTR.If I2CxCNT is not ‘0’, the hardware transmits the
value of the ACKDT bit as the ACK value to the master.
It is up to the user to configure the ACKDT bit appropriately. In most cases,
the ACKDT bit should be cleared, so that the master receives an
ACK (logic low level on SDA during the 9th SCL
pulse).
If I2CxCNT = 0, the hardware
transmits the value of the Acknowledge End of Count (ACKCNT) bit as the
ACK value to the slave. It is up to the user to
properly define the ACKCNT bit. In most cases, this bit should be set,
indicating a NACK condition. When the master hardware detects the NACK on the
bus, the master hardware will also generate a Stop condition. If the ACKCNT bit
is cleared, an ACK will be issued, and the master
hardware will not automatically generate the Stop condition.
0, or until the master issues a Stop condition.