29.3.2.2.5 Receiving Data Packets
Assuming the M2 case above, the clock is released for one byte, allowing the client to put
one byte of data on the bus. The host will receive one data byte from the client, and the
Read Interrupt Flag (RIF) will be set to ‘1
’ together with the Clock Hold
(CLKHOLD) flag. The action selected by the Acknowledge Action (ACKACT) bit in the Host
Control B (TWIn.MCTRLB) register is automatically sent on the bus when a command is written
to the Command (MCMD) bit field in the TWIn.MCTRLB register.
- Respond with an ACK by writing
‘
0
’ to the ACKACT bit in the TWIn.MCTRLB register and prepare to receive a new data packet - Respond with a NACK by writing
‘
1
’ to the ACKACT bit and then transmit a new address packet - Respond with a NACK by writing
‘
1
’ to the ACKACT bit and then complete the transaction by issuing a Stop condition in the MCMD bit field from the TWIn.MCTRLB register
A NACK response might not execute successfully, as the arbitration can be lost during the
transmission. If a collision is detected, the host loses the arbitration, the Arbitration
Lost (ARBLOST) flag is set to ‘1
’, and the bus state changes to Busy. The
Host Write Interrupt Flag (WIF) is set if the arbitration was lost when sending a NACK or a
bus error occurred during the procedure. An arbitration lost while transferring the data
packet is treated as the above M4 case.
The RIF, CLKHOLD, ARBLOST and WIF flags are all located in the Host Status (TWIn.MSTATUS) register.