GD32W51x User Manual
645
transmission. If the TIE bit in I2C_CTL0 register is set, an interrupt will be generated. The
bytes to be transferred is programmed in BYTENUM[7:0] in I2C_CTL0 register. If the bytes to
be transferred is greater than 255, RELOAD bit in I2C_CTL0 register must be set to enable
the reload mode. In reload mode, when data of BYTENUM[7:0] bytes have been transferred,
the TCR bit in I2C_STAT register will be set and the SCL stretches unitil BYTENUM[7:0] is
modified with a non-zero value.
When a NACK is received, the TI bit will not set.
If data of BYTENUM[7:0] bytes have been transferred and RELOAD=0, the AUTOEND
bit in I2C_CTL1 can be set to generate a STOP condition automatically. When
AUTOEND is 0, the TC bit in I2C_STAT register will be set and the SCL is stretched. In
this case, the master can generate a STOP condition by setting the STOP bit in the
I2C_CTL1 register. Or generate a RESTART condition to start a new transfer. The TC bit
is cleared when the START/STOP bit is set.
If a NACK is received, a STOP condition is automatically generated, the NACK is set in
I2C_STAT register, if the NACKIE bit is set, an interrupt will be generated.
Note:
When the RELOAD bit is 1, the AUTOEND has no effect.
Figure 19-18. Programming model for master transmitting (N<=255)
IDLE
Master generates START
condition
Master sends Address
Slave sends Acknowledge
Wait for ACK from slave
Master sends DATA(1)
Slave sends Acknowledge
……
(
Data transmission
)
Master sends DATA(N-2)
Slave sends Acknowledge
Master sends DATA(N)
Slave sends Acknowledge
Master generates STOP
condition, clear TC
Software initialization
Set TI
Set TI
Set TI
Write DATA(1) to I2C_TDATA
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
Master sends DATA(N-1)
Slave sends Acknowledge
Set TI
Set STOP
I2C Line State
Hardware Action
Software Flow
Set START
AUTOEND=0
BYTENUM[7:0]=N
Set TC