37.3.10 Receive Buffer
The I2C module has a dedicated receive buffer, I2CxRXB, which is independent from the transmit buffer.
Data received through the shift register is transferred to I2CxRXB when
the byte is complete. User software or the DMA can access the byte by reading the
I2CxRXB register. When new data are loaded into I2CxRXB, the Receive Buffer Full Status
(RXBF) bit is set, allowing user software or the DMA to read the
new data. When the RXBF bit is set, the I2C Receive Interrupt Flag (I2CxRXIF)
bit of the PIR registers is set and can be used to trigger the DMA. A read of the
I2CxRXB register will clear both RXBF and I2CxRXIF bits. Setting the CLRBF bit clears the I2CxRXIF bit and the I2CxRXB and I2CxTXB
registers.
If the buffer is read while empty (RXBF =
0
), the Receive Read Error Status (RXRE) bit is set, and the module generates a NACK. User software
must clear RXRE to resume normal operation.When the module attempts to transfer the contents of the receive shift
register to I2CxRXB while I2CxRXB is full (RXBF =
1
), the Receive Overflow Status (RXO) bit is set, and a NACK is generated. The data currently
stored in I2CxRXB remains unchanged, but the data in the receive shift register is
lost.Important: A receive overflow can
only occur when clock stretching is disabled. Clock stretching prevents receive
overflows because the receive shift register cannot receive any more data until user
software or the DMA reads I2CxRXB and the SCL line is released.