GD32A50x User Manual
519
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.
Figure 20-13. I2C initialization in slave mode
I2CEN=0
Configure DNF[3:0] in I2C_CTL0
START
Configure PSC[3:0], SDADELY[3:0],
SCLDELY[3:0] in I2C_TIMING
Configure SS in I2C_CTL0
I2CEN=1
FINISH
Clear ADDRESSEN in I2C_SADDR0
Clear ADDRESS2EN in I2C_SADDR1
Configure ADDRESS[9:0], ADDFORMAT and
ADDRESSEN in I2C_SADDR0,
ADDRESS2[7:1], ADDMSK2[2:0] and
ADDRESS2EN in I2C_SADDR1, ADDM[6:0] in
I2C_CTL2
Configure SBCTL in I2C_CTL0
Programming model in slave transmitting mode
When the I2C_TDATA register is empty, the TI bit in I2C_STAT register will be set. If the TIE
bit in I2C_CTL0 register is set, an interrupt will be generated. The NACK bit in I2C_STAT
register will be set when a NACK is received. And an interrupt is generated if the NACKIE bit
is set in the I2C_CTL0 register. The TI bit in I2C_STAT register will not be set when a NACK
is received.
The STPDET bit in I2C_STAT register will be set when a STOP is received. If the STPDETIE
in I2C_CTL0 register is set, an interrupt will be generated.