37.4.2.7.1 Host Transmission (7-Bit Addressing Mode)
The following section describes the sequence of events that occur when the module is transmitting data in 7-bit Addressing mode:
- Depending on the configuration of the
Address Buffer Disable (ABD) bit, one of two methods may be used to begin
communication:
- When ABD is clear (ABD =
0
), the address buffer, I2CxADB1, is enabled. In this case, the 7-bit client address and R/W bit are loaded into I2CxADB1, with the R/W bit clear (R/W =0
). The number of data bytes are loaded into I2CxCNT, and the first data byte is loaded into I2CxTXB. After these registers are loaded, software must set the Start (S) bit to begin communication. Once the S bit is set, host hardware waits for the Bus Free (BFRE) bit to be set before transmitting the Start condition to avoid bus collisions. - When ABD is set (ABD =
1
), the address buffer is disabled. In this case, the number of data bytes are loaded into I2CxCNT, and the client’s 7-bit address and R/W bit are loaded into I2CxTXB. A write to I2CxTXB will cause host hardware to automatically issue a Start condition once the bus is Idle (BFRE =1
). Software writes to the Start bit are ignored.
- When ABD is clear (ABD =
- Host hardware waits for BFRE to be set, then shifts out the Start condition. Module hardware sets the Host Mode Active (MMA) bit and the Start Condition Interrupt Flag (SCIF). If the Start Condition Interrupt Enable (SCIE) bit is set, the generic I2CxIF is also set.
- Host hardware transmits the 7-bit client address and R/W bit.
- If upon the 8th falling edge of SCL,
I2CxTXB is empty (Transmit Buffer Empty Status (TXBE) =
1
), I2CxCNT is nonzero (I2CxCNT !=0
), and the Clock Stretching Disable (CSD) bit is clear (CSD =0
):- The I2C Transmit Interrupt Flag (I2CxTXIF) is set. If the I2C Transmit Interrupt Enable (I2CxTXIE) bit is also set, the generic I2CxIF is also set.
- The Host Data Request (MDR) bit is set, and the clock is stretched, allowing time for software to load I2CxTXB with new data. Once I2CxTXB has been written, hardware releases SCL and clears MDR.
- Hardware transmits the 9th clock pulse and waits for an ACK/NACK response from the client. If the host receives an ACK, module hardware transfers the data from I2CxTXB into the transmit shift register, and I2CxCNT is decremented by one. If the host receives a NACK, hardware will attempt to issue a Stop condition. If the clock is currently being stretched by a client, the host must wait until the bus is free before issuing the Stop.
- Host hardware checks I2CxCNT
for a zero value. If I2CxCNT is zero:
- If ABD is clear (ABD =
0
), host hardware issues a Stop condition or sets MDR if the Restart Enable (RSEN) bit is set and waits for software to set the Start bit to issue a Restart condition. CNTIF is set. - If ABD is set (ABD =
1
), host hardware issues a Stop condition or sets MDR if RSEN is set and waits for software to load I2CxTXB with a new client address. CNTIF is set.
- If ABD is clear (ABD =
- Host hardware transmits the data byte.
- If upon the 8th falling edge of SCL
I2CxTXB is empty (TXBE =
1
), I2CxCNT is nonzero (I2CxCNT !=0
), and CSD is clear (CSD =0
): - Repeat Steps 5 – 8 until all data has been transmitted.