GD32A50x User Manual
525
Figure 20-19. 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(253)
Slave sends Acknowledge
Master sends DATA(255)
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(255) to
I2C_TDATA
Master sends DATA(254)
Slave sends Acknowledge
Set TI
Set STOP
I2C Line State
Hardware Action
Software Flow
Set START
RELOAD =1
BYTENUM[7:0]=0xFF
N=N-255
Set TCR
Reload
BYTENUM[7:0]=N
Set TI
Write DATA(1) to
I2C_TDATA
Master sends DATA(1)
Slave sends Acknowledge
(
Data transmission
)
Master sends DATA(N-2)
Slave sends Acknowledge
Set TI
Set TI
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
Master sends DATA(N)
Slave sends Acknowledge
Set TC
Programming model in master receiving mode
In master receiving mode, the RBNE bit in I2C_STAT register will be set when a byte is
received. If the RBNEIE bit is set in I2C_CTL0 register, an interrupt will be generated. If the
number of bytes to be received 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.
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 signalautomatically. 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 signalby setting the STOP bit in the I2C_CTL1 register. Or generate a
RESTART signalto start a new transfer. The TC bit is cleared when the START/STOP bit is
set.