GD32A50x User Manual
522
Figure 20-16. Programming model for slave receiving
IDLE
Master generates START
condition
Master sends Address
Slave sends Acknowledge
SCL stretched by slave
(only when SS=0)
Master sends DATA(1)
Slave sends Acknowledge
……
(
Data transmission
)
Master sends DATA(N)
Slave sends Acknowledge
Master generates STOP
condition
Set ADDSEND
read READDR and TR in
I2C_STAT, clear ADDSEND
Set RBNE
Set STPDET
Read DATA(x)
Set RBNE
Read DATA(1)
Read DATA(N)
Clear STPDET
I2C Line State
Hardware Action
Software Flow
Set RBNE
Software initialization
20.3.8.
I2C master mode
Initialization
The SCLH[7:0] and SCLL[7:0] in I2C_TIMING register should be configured when I2CEN is
0. In order to support multi-master communication and slave clock stretching, a clock
synchronization mechanism is implemented.
The SCLL[7:0] and SCLH[7:0] are used for the low level counting and high level couting
respectively. After a t
SYNC1
delay, when the SCL low level is detected, the SCLL[7:0] starts
counting, if the SCLL[7:0] in I2C_TIMING register is reached by SCLL[7:0] counter, the I2C
will release the SCL clock. After a t
SYNC2
delay, when the SCL high level is detected, the
SCLH[7:0] starts counting, if the SCLH[7:0] in I2C_TIMING register is reached by SCLH[7:0]
counter, the I2C will stretch the SCL clock.
So the master clock period is:
t
SCL
=t
SYNC1
+t
SYNC2
+{[
(
SCLH
[
7:0
]
+1
)
+(SLLL
[
7:0
]
+1)]*(PSC+1)*t
I2CCLK
}.
The t
SYNC1
depends on the SCL falling slope, delay by input analog and digital noise filter
and SCL synchronization with I2CCLK clock, which generally 2 to 3 I2CCLK periods. The
t
SYNC2
depends on the SCL rising slope, delay by input analog and digital noise filter and SCL
synchronization with I2CCLK clock, which generally 2 to 3 I2CCLK periods. The delay by
digital noise filter is DNF[3:0]*t
I2CCLK
.
When works in master mode, the ADD10EN bit, SADDRESS[9:0] bits, TRDIR bit should be