31.4.2.2.2 Transmitting Address Packets
The I2C host starts a bus transaction by writing the I2C client address and direction bit to ADDR.ADDR. If the bus is busy, the I2C host waits until the bus becomes idle before continuing the operation. When the bus is IDLE, the I2C host issues a Start condition on the bus and then transmits an address packet using the address written to ADDR.ADDR. After the address packet is transmitted by the I2C host, one of four cases arises, depending on according to arbitration and transfer direction.
Case 1: Arbitration lost or bus error during address packet transmission
If arbitration was lost during transmission of the address packet, the Host on Bus bit in the Interrupt Flag Status and Clear register (INTFLAG.MB) and the Arbitration Lost bit in the STATUS register (STATUS.ARBLOST) are both set. Serial data output to SDA is disabled, and the SCL is released, which disables clock stretching. In effect, the I2C host is no longer allowed to execute any operation on the bus until the bus is idle again. A bus error will behave similarly to the arbitration lost condition. In this case, the MB interrupt flag and Host Bus Error bit in the STATUS register (STATUS.BUSERR) are both set in addition to STATUS.ARBLOST.
The Host Received Not Acknowledge bit in the STATUS register (STATUS.RXNACK) always containd the last successfully received acknowledge or not acknowledge indication.
In this case, software typically informs the application code of the condition and then clears the interrupt flag before exiting the interrupt routine. No other flags need to be cleared at this point, because all flags are automatically cleared the next time the ADDR.ADDR register is written.
Case 2: Address packet transmit complete – No ACK received
If no I2C client device responds to the address packet, the INTFLAG.MB interrupt flag and STATUS.RXNACK are set. Clock hold is active at this point, preventing further activity on the bus.
A missing ACK response can indicate that the I2C client is busy with other tasks or in a sleep state and is therefore unable to respond. In this case, the next step can be either issuing a Stop condition (recommended) or resending the address packet using a repeated Start condition. When using SMBus logic, the client must ACK the address. If there is no response, the client is not available on the bus.
Case 3: Address packet transmit complete – Write packet, Host on Bus set
If the I2C host receives an acknowledge response from the I2C client, INTFLAG.MB is set and STATUS.RXNACK is cleared. Clock hold is active at this point, preventing further activity on the bus.
- Initiate a data transmit operation by writing the data byte to be transmitted to DATA.DATA
- Transmit a new address packet by writing to ADDR.ADDR. A repeated Start condition is automatically inserted before the address packet.
- Issue a stop condition, thereby terminating the transaction
Case 4: Address packet transmit complete – Read packet, Client on Bus set
If the I2C host receives an ACK from the I2C client, the host proceeds to receive the next byte of data from the client. When the first data byte is received, the Client on Bus bit in the Interrupt Flag register (INTFLAG.SB) is set and STATUS.RXNACK is cleared. Clock hold is active at this point, preventing further activity on the bus.
- Allow the I2C host to continue reading data by acknowledging the received data. The ACK can be sent by software or automatically in Smart mode.
- Transmit a new address packet
- Terminate the transaction by issuing a Stop condition
