Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
430
/
631
2
、
After receiving the START condition and the matched 7-bit or 10-bit address, I2C hardware will set
I2C_STS1.ADDRF bit(the address received and matched with its own address) to 1. This bit should be detected
by software polling or interrupt. After it is found that it is set, the software clears the I2C_STS1.ADDRF bit by
reading I2C_STS1 register first and then I2C_STS2 register. Once the I2C_STS1.ADDRF bit is cleared,The I2C
slave starts to receive data from the I2C bus.
3
、
When the first byte is received, the I2C_STS1.RXDATNE bit (the received data is not empty) is set to 1 by
hardware. If the I2C_CTRL2.EVTINTEN and I2C_CTRL2.BUFINTEN bits are set, an interrupt is generated.
The software should check this bit by polling or interrupt. Once it is found that it is set, the software can read the
first byte of I2C_DAT register, and then the I2C_STS1.RXDATNE bit is cleared to 0. Note that if the
I2C_CTRL1.ACKEN bit is set, after receiving a byte,the slave should generate a response pulse.
4
、
At any time, as long as the I2C_STS1.RXDATNE bit is set to 1, the software can read a byte from the I2C_DAT
register. When the last byte is received, I2C_STS1.RXDATNE is set to 1 and the software reads the last byte.
5
、
When the slave detects the STOP bit on I2C bus, set I2C_STS1.STOPF to 1, and if the I2C_CTRL2.EVTINTEN
bit is set, an interrupt will be generated. The software clears the I2C_STS1.STOPF bit by reading the I2C_STS1
register before writing the I2C_CTRL1 register (see EV4 in the following figure).
Figure 21-4 Slave receiver transfer sequence diagram
Instructions
:
1.
EV1: I2C_STS1.ADDRF = 1, read STS1 and then STS2 to clear the event.
2.
EV2: I2C_STS1.RXDATNE =1, reading DAT will clear this event.
3.
EV4: I2C_STS1.STOPF=1, reading STS1 and then writing the CTRL1 register will clear this event.
Note: a)EV1 event prolongs the time when SCL is low until the end of the corresponding software sequence.
b) The software sequence of EV2 must be completed before the end of the current byte transmission.
Start
Address(W)
ACK
EV1
Data1
ACK
Data2
ACK
EV2
DataN
ACK
Stop
ACK Address
ACK
EV1
Data1
ACK
Start Header(W)
Master
Tx
Master
Tx
Sl ave
Tx
Master
Tx
Master
Tx
Sl ave
Tx
Sl ave
Tx
Sl ave
Tx
Master
Tx
Master
Tx
DataN
ACK
Stop
EV4
Sl ave
Tx
Master
Tx
Master
Tx
EV2
EV2
Master
Tx
Master
Tx
Sl ave
Tx
Master
Tx
Sl ave
Tx
Sl ave
Tx
Master
Tx
10-bit address
7-bit address
EV4
EV2
EV2