GD32W51x User Manual
641
When SS=1, the SCL will not be stretched when ADDSEND bit in I2C_STAT register is set.
In this case, the data in I2C_TDATA register can not be flushed in ADDSEND interrupt service
routine. So the first data byte to be sent must be programmed in the I2C_TDATA register
previously.
This data can be the data written in the last TI event of the last transfer.
If the data is not the one to be sent, setting the TBE bit can flush the data, then a new
byte can be written in I2C_TDATA register. Then the STPDET bit should be cleared. The
STPDET must be 0 when the data transmission begins. Or else the OUERR bit in
I2C_STAT register will be set and an underrun error occurs.
When interrupt or DMA is used in slave transmitter, if a TI event is needed, in order to
generate a TI event both the TI bit and the TBE bit must be set.
Figure 19-14. Programming model for slave transmitting when SS=0
IDLE
Master generates START
condition
Master sends Address
Slave sends Acknowledge
SCL stretched by slave
Slave sends DATA(2)
Master sends Acknowledge
……
(
Data transmission
)
Slave sends DATA(N-1)
Master sends Acknowledge
Slave sends DATA(N)
Master don't send ACK
Master generates STOP
condition
I2C initialization
Set ADDSEND
read READDR and TR in
I2C_STAT, set TBE or not,
clear ADDSEND
Set TI
Set TI
Write DATA(1) to I2C_TDATA if
TBE has been set
Write DATA(x) to I2C_TDATA
Set TI
Write DATA(2) to I2C_TDATA
Write DATA(3) to I2C_TDATA
Write DATA(N) to I2C_TDATA
Set TI, set NACK
I2C Line State
Hardware Action
Software Flow
Slave sends DATA(1)
Master sends Acknowledge
Write DATA(N+1) to I2C_TDATA
DATA(N+1) will not be sent
Clear NACK
Clear STPDET