GD32F403xx User Manual
434
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 the last byte is received, RBNE is set. Software reads the last byte.
6.
STPDET bit is set when I2C detects a STOP signal on I2C bus and software reads
I2C_STAT0 and then writes I2C_CTL0 to clear the STPDET bit.
Figure 18-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
Figure 18-11. Programming model for master transmitting mode (10-bit
, the following software procedure should be followed if users wish to make
transaction in master transmitter mode:
1.
First of all, 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 signal followed by address on I2C bus.
2.
Software sets START bit requesting I2C to generate a START signal on I2C bus.