GD32W51x User Manual
639
In slave transmitting mode, the data should be written in the I2C_TDATA register before
the first SCL pulse corresponding to its transfer occurs. Or else the OUERR bit in the
I2C_STAT register will be set, if the ERRIE bit is set, an interrupt will be generated. When
the STPDET bit is set and the first data transmission starts, OUERR bit in the I2C_STAT
register will also be set.
In slave receiving mode, the data must be read from the I2C_RDATA register before the
9th SCL pulse (ACK pulse) occurred by the next data byte. Or else the OUERR bit in the
I2C_STAT register will be set, if the ERRIE bit is set, and an interrupt will be generated.
Slave byte control mode
In slave receiving mode, the slave byte control mode can be enabled by setting the SBCTL
bit in the I2C_CTL0 register to allow byte ACK control. When SS=1, the slave byte control
mode is not allowed.
When using slave byte control mode, the reload mode must be enabled by setting the
RELOAD bit in I2C_CTL1 register. In order to get control of each byte, BYTENUM[7:0] in
I2C_CTL1 register must be configured as 1 in the ADDSEND interrupt service routine and
reloaded to 1 after each byte received. The TCR bit in I2C_STAT register will be set when a
byte is received, the slave stretchs the SCL low between the 8th and 9th clock pulses. Then
the data can be read from the I2C_RDATA register, and the slave determined to send an ACK
or a NACK by configuring the NACKEN bit in the I2C_CTL1 register. When the BYTENUM[7:0]
is written a non-zero value, the slave will release the stretch. The ACK or NACK is sent and
the next byte can be received.
When the BYTENUM[7:0] is greater than 0x1, there is no stretch between the reception of
two data bytes.
Note:
The SBCTL bit can be configured in
following cases:
1.
I2CEN=0.
2.
The slave has not been addressed.
3.
ADDSEND=1.
Only when the ADDSEND=1, or TCR=1, the RELOAD bit can be modified.