Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
429
/
631
5
、
After the first byte is sent, I2C_STS1.TXDATE is set again, and the software writes the third byte to I2C_DAT,
the same time, the I2C_STS1.TXDATE bit is cleared.After that, as long as there is still data to be sent and
I2C_STS1.TXDATE is set to 1, the software can write a byte to I2C_DAT register.
6
、
During the sending of the second last byte, the software writes the last data to the I2C_DAT register to clear the
I2C_STS1.TXDATE flag bit, and then the I2C_STS1.TXDATE status is no longer concerned.
I2C_STS1.TXDATE bit is set after the second last byte is sent until the stop end bit is detected.
7
、
According to the I2C protocol, the I2C master will not send a ACK to the last byte received. Therefore, after the
last byte is sent, the I2C_STS1.ACKFAIL bit (acknowledge fail) of the I2C slave will be set to notify the software
of the end of sending. The software writes 0 to the I2C_STS1.ACKFAIL bit to clear this bit.
Figure 21-3 Slave transmitter transfer sequence diagram
Instructions
:
1.
EV1: I2C_STS1.ADDRF = 1, read STS1 and then STS2 register to clear the event.
2.
EV3-1: I2C_STS1.TXDATE=1, shift register is empty, data register is empty, write DAT.
3.
EV3: I2C_STS1.TXDATE=1, shift register is not empty, data register is empty, write DAT will clear the event.
4.
EV3-2: I2C_STS1.ACKFAIL=1, ACKFAIL bit of STS1 register write "0" to clear the event.
Note: a) EV1 and EV3_1 event prolongs the low SCL time until the end of the corresponding software sequence.
b) The software sequence of EV3 must be completed before the end of the current byte transfer.
I2C slave receiving mode
When receiving data in slave mode, the software should operate as follows:
1
、
First, enable I2C peripheral clock and configure the clock related register in I2C_CTRL1 ensuring the correct
I2C timing. After these two steps are completed, I2C runs in slave mode, waiting for receiving start bit and
address.
Start
Address(R)
ACK
EV1 EV3-1
EV3
Data1
ACK
Data2
ACK
EV3
DataN
NACK Stop
EV3-2
ACK Address
ACK
EV1
Data1
ACK
Start Header(W)
Master
Tx
Master
Tx
Sl ave
Tx
Sl ave
Tx
Sl ave
Tx
Master
Tx
Master
Tx
Master
Tx
Master
Tx
Sl ave
Tx
Start
Header(R)
ACK
EV1 EV3-1
EV3
DataN
NACK Stop
EV3-2
Master
Tx
Master
Tx
Sl ave
Tx
EV3
EV3
Master
Tx
Master
Tx
Sl ave
Tx
Master
Tx
Sl ave
Tx
Master
Tx
Master
Tx
Master
Tx
Sl ave
Tx
Sl ave
Tx
10-bit address
7-bit address