36.3.9 Transmit Buffer
The I2C module has a dedicated transmit buffer, I2CxTXB, which is independent from the receive buffer.
The transmit buffer is loaded with an address byte (when ABD =
1
), or a data byte, that is copied into the transmit shift register
and transmitted onto the bus. When the I2CxTXB register does not contain any transmit
data, the Transmit Buffer Empty Status (TXBE)
bit is set (TXBE = 1
), allowing user software or the DMA to load a new
byte into the buffer. When the TXBE bit is set and the I2CxCNT register is non-zero
I2CxCNT( != 0
), the I2C Transmit Interrupt Flag (I2CxTXIF)
bit of the PIR registers is set and can be used as a DMA trigger. A write to I2CxTXB
will clear both the I2CxTXB and I2CxTXIF bits. Setting the Clear Buffer (CLRBF) bit clears I2CxTXIF, the I2Cx Receive Buffer (I2CxRXB) and I2CxTXB.If user software attempts to load I2CxTXB while it is full, the Transmit Write Error
Status (TXWE) bit is set, a NACK is generated, and the new data are ignored. If TXWE
is set, user software must clear the bit before attempting to load the buffer again.
When module hardware attempts to transfer the contents of I2CxTXB to the
transmit shift register while I2CxTXB is empty (TXBE =
1
), the Transmit Underflow Status (TXU) bit is set, I2CxTXB is loaded with 0xFF
,
and a NACK is generated.Important: A transmit underflow
can only occur when clock stretching is disabled (Clock Stretching Disable (CSD) bit =
1
). Clock stretching prevents
transmit underflows because the clock is stretched after the 8th falling SCL edge, and
is only released upon the write of new data into I2CxTXB.