GD32VF103 User Manual
360
Figure 17-9. Programming model for slave transmitting(10-bit address mode)
IDLE
Master generates START
condition
Master sends Address
Slave sends Acknowledge
Master generates repeated
START condition
Master sends header
Slave sends Acknowledge
SCL stretched by slave
Slave sends DATA(1)
Master sends Acknowledge
……
(
Data transmission
)
Slave sends DATA(N-2)
Master sends Acknowledge
Slave sends DATA(N)
Master DON'T send Ack
Master generates STOP
condition
1) Software initialization
Set ADDSEND
2) Clear ADDSEND
Set ADDSEND
2) Clear ADDSEND
Set TBE
Set TBE
Set TBE
Set AERR
Clear TBE
3) Write DATA(1) to I2C_DATA
Write DATA(x) to I2C_DATA
Set TBE
4) Write DATA(2) to I2C_DATA
5) Write DATA(3) to I2C_DATA
6)Write DATA(N) to I2C_DATA
Slave sends DATA(N-1)
Master sends Acknowledge
Set TBE
7) Clear AERR
I2C Line State
Hardware Action
Software Flow
Master sends Header
Slave sends Acknowledge
Programming model in slave receiving mode
Figure 17-10. Programming model for slave receiving(10-bit address
the following software procedure should be followed if users wish to make reception
in slave receiver 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.
2.
After receiving a START condition followed by a matched 7-bit or 10-bit address, the I2C
hardware sets the ADDSEND bit in I2C status register, which should be monitored by
software either by polling or interrupt. After that software should read I2C_STAT0 and