27.3.2.3.1 Receiving Address Packets

When the TWI is configured as a slave, it will wait for a Start condition to be detected. When this happens, the successive address packet will be received and checked by the address match logic. The slave will ACK a correct address and store the address in the Slave Data (TWIn.SDATA) register. If the received address is not a match, the slave will not acknowledge or store the address, but wait for a new Start condition.

The Address or Stop Interrupt Flag (APIF) in the Slave Status (TWIn.SSTATUS) register is set to ‘1’ when a Start condition is succeeded by one of the following:

  • A valid address match with the address stored in the Address (ADDR[7:1]) bit field in the Slave Address (TWIn.SADDR) register
  • The General Call Address 0x00 and the Address (ADDR[0]) bit in the Slave Address (TWIn.SADDR) register are set to ‘1
  • A valid address match with the secondary address stored in the Address Mask (ADDRMASK) bit field and the Address Mask Enable (ADDREN) bit is set to ‘1’ in the Slave Address Mask (TWIn.SADDRMASK) register
  • Any address if the Address Recognition Mode (PMEN) bit in the Slave Control A (TWIn.SCTRLA) register is set to ‘1

Depending on the Read/Write Direction (DIR) bit in the Slave Status (TWIn.SSTATUS) register and the bus condition, one of four distinct cases (S1 to S4) arises after the reception of the address packet.

Figure 27-6. TWI Slave Operation