GD32A50x User Manual
518
low if necessary. The SCL will be stretched in following cases.
The SCL is stretched when the ADDSEND bit is set, and released when the ADDSEND
bit is cleared.
In slave transmitting mode, after the ADDSEND bit is cleared, the SCL will be stretched
before the first data byte writing to the I2C_TDATA register. Or the SCL will be stretched
before the new data is written to the I2C_TDATA register after the previous data
transmission is completed.
In slave receiving mode, a new reception is completed but the data in I2C_RDATA
register has not been read.
When SBCTL=1 and RELOAD=1, after the transfer of the last byte, TCR is set. Before
the TCR is cleared, the SCL will be stretched.
The I2C stretches SCL low during [
(
1
)
*
(
PSC+1
)
+1]*t
I2CCLK
after
detecting the SCL falling edge.
The clock stretching can be disabled by setting the SS bit in I2C_CTL0 register (SS=1). The
SCL will not be stretched in following cases.
When the ADDSEND is set, the SCL will be not stretched.
In slave transmitting mode, before the first SCL pulse, the data must be written in the
I2C_TDATA register . 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, before the 9th SCL pulse (ACK pulse) occurred by the next data
byte, the data must be read out from the I2C_RDATA register. 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 slave byte control mode, 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 SCL will be stretched low by slave between the 8th and 9th clock pulses. Then the data
can be read from the I2C_RDATA register, and the slave determines 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.
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: