GD32VF103 User Manual
361
then I2C_STAT1 to clear ADDSEND bit. The I2C begins to receive data to I2C bus as
soon as ADDSEND bit is cleared.
3.
As soon as the first byte is received, RBNE is set by hardware. Software can now read
the first byte from I2C_DATA and RBNE is cleared as well.
4.
Any time RBNE is set, software can read a byte from I2C_DATA.
5.
After last byte is received, RBNE is set. Software reads the last byte.
6.
STPDET bit is set when I2C detects a STOP condition on I2C bus and software reads
I2C_STAT0 and then write I2C_CTL0 to clear the STPDET bit.
Figure 17-10. Programming model for slave receiving(10-bit address mode)
IDLE
Master generates START
condition
Master sends Header
Slave sends Acknowledge
Master sends Address
Slave sends Acknowledge
SCL stretched by slave
Master sends DATA(1)
Slave sends Acknowledge
……
(
Data transmission
)
Master sends DATA(N)
Slave sends Acknowledge
Master generates STOP
condition
Set ADDSEND
2) Clear ADDSEND
Set RBNE
Set STPDET
4) Read DATA(x)
Set RBNE
3) Read DATA(1)
5) Read DATA(N)
6) Clear STPDET
I2C Line State
Hardware Action
Software Flow
Set RBNE
1) Software initialization
Programming model in master transmitting mode
As it shows in
Figure 17-11. Programming model for master transmitting(10-bit address
, the following software procedure should be followed if users wish to make transaction
in master transmitter mode:
1.
First of all, software should enable I2C peripheral clock as well as configure clock related
registers in I2C_CTL1 to make sure correct I2C timing. After enabled and configured,
I2C operates in its default slave state and waits for START condition followed by address
on I2C bus.