A master device can transmit a read request to a slave, and then clock data out of the slave. The list below outlines what software for a slave will need to do to accomplish a standard transmission. Figure 1 can be used as a reference to this list.
- 1.Master sends a Start condition on SDA and SCL.
- 2.S bit is set; SSPxIF is set if interrupt on Start detect is
enabled.
- 3.Matching address with R/W bit set is received by the Slave setting SSPxIF bit.
- 4.Slave hardware generates an ACK and sets SSPxIF.
- 5.SSPxIF bit is cleared by user.
- 6.Software reads the received address from SSPxBUF, clearing
BF.
- 7.R/W is set so
CKP was automatically cleared after the ACK.
- 8.The slave software loads the transmit data into SSPxBUF.
- 9.CKP bit is set releasing SCL, allowing the master to clock the
data out of the slave.
- 10.SSPxIF is set after the ACK response from the master is loaded into the ACKSTAT register.
- 11.SSPxIF bit is cleared.
- 12.The slave software checks the ACKSTAT bit to see if the master wants to clock out more data.
Important:
- 1.If the master
ACKs then the clock will be stretched.
- 2.ACKSTAT is the only bit
updated on the rising edge of the ninth SCL clock instead of the falling
edge.
- 13.Steps 9-13 are repeated for each transmitted byte.
- 14.If the master sends a not ACK; the clock is not held, but SSPxIF is still set.
- 15.The master sends a Restart condition or a Stop.
- 16.The slave is no longer addressed.
Figure 1. I2C
Slave, 7-bit Address, Transmission (AHEN = 0
)