GD32A50x User Manual
520
When SBCTL is 0, if ADDSEND=1, and the TBE bit in I2C_STAT register is 0, the data in
I2C_TDATA register can be chosed to be transmitted or flushed. The data is flushed by setting
the TBE bit.
When SBCTL=1, the slave works in slave byte control mode, the BYTENUM[7:0] must be
configured in the ADDSEND interrupt service routine. And the number of TI events is equal
to the value of BYTENUM[7:0].
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 byte to be sent must be programmed in the I2C_TDATA register previously.
This data can be the one which is written in the last TI event of the last transfer.
Setting the TBE bit can flush the data if it is not the one to be sent, then a new byte can
be written in I2C_TDATA register. 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 20-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