GD32W51x User Manual
637
Table 19-3. Communication modes to be shut down
Working m ode
Action
Master mode
NACK, STOP and RESTART generation
Slave receiver mode
ACK control
SMBus mode
PEC generation/checking
The byte counter is always used in master mode. It is disabled in slave mode by default, but
it can be enabled by software by setting the SBCTL (slave byte control) bit in the I2C_CTL0
register.
The number of bytes to be transferred is programmed in the BYTENUM[7:0] bit field of the
I2C_CTL1 register. If the number of bytes to be transferred (BYTENUM) is greater than 255,
or if a receiver wants to control the acknowledge value of a received data byte, the reload
mode must be selected by setting the RELOAD bit in the I2C_CTL1 register. In this mode,
TCR flag is set when the number of bytes programmed in BYTENUM has been transferred,
and an interrupt is generated if TCIE is set. Once the TCR flag is set, SCL is stretched. When
BYTENUM is written to a non-zero value, TCR is cleared by software.
When the BYTENUM counter is reloaded with the last number of bytes, RELOAD bit must be
cleared.
When RELOAD = 0 in master mode, the counter can be used in two modes:
Automatic end mode
(AUTOEND = 1 in the I2C_CTL1 register). In this mode, once the
number of bytes programmed in the BYTENUM[7:0] bit field has been transferred, the
master automatically sends a STOP condition. Note that when the RELOAD bit is set,
the AUTOEND bit has no effect.
Software end mode
(AUTOEND = 0 in the I2C_CTL1 register). In this mode, once the
number of bytes programmed in the BYTENUM[7:0] bit field has been transferred, the
TC flag is set and an interrupt is generated if the TCIE bit is set. As long as the TC flag
is set, the SCL signal is stretched. When the START or STOP bit is set in the I2C_CTL1
register, the TC flag is cleared by software. This mode must be used when the master
wants to send a RESTART condition.
Table 19-4. I2C configuration
Function
SBCTL bit
RELOAD bit
AUTOEND bit
Master Tx/Rx + BYTENUM + STOP
x
0
1
Master Tx/Rx + BYTENUM + RESTART
x
0
0
Slave Tx/Rx all received bytes ACKed
0
x
x
Slave Rx w ith ACK control
1
1
x