GD32F20x User Manual
524
Figure 20-9. Programming model for slave transmitting
IDLE
Master generates START
condition
Master sends Address
Slave sends Acknowledge
Master generates repeated
START condition
Master sends header
Slave sends Acknowledge
SCL stretched by slave
Slave sends DATA(1)
Master sends Acknowledge
……
(
Data transmission
)
Slave sends DATA(N-2)
Master sends Acknowledge
Slave sends DATA(N)
Master DON'T send Ack
Master generates STOP
condition
1) Software initialization
Set ADDSEND
2) Clear ADDSEND
Set ADDSEND
2) Clear ADDSEND
Set TBE
Set TBE
Set TBE
Set AERR
Clear TBE
3) Write DATA(1) to TRB
Write DATA(x) to TRB
Set TBE
4) Write DATA(2) to TRB
5) Write DATA(3) to TRB
6)Write DATA(N) to TRB
Slave sends DATA(N-1)
Master sends Acknowledge
Set TBE
7) Clear AERR
I2C Line State
Hardware Action
Software Flow
Master sends Header
Slave sends Acknowledge
Programming model in slave receiving mode
As is shown in
Figure 20-10. Programming model for slave receiving
, the following
software procedure should be followed if users wish to make reception in slave receiver mode:
1.
First of all, software should enable I2C peripheral clock as well as configure clock related
registers in I2C_CTL1 to make sure correct I2C timing. After enabled and configured,
I2C operates in its default slave state and waits for START condition followed by address
on I2C bus.
2.
After receiving a START condition followed by a matched 7-bit or 10-bit address, the I2C
hardware sets the ADDSEND bit in I2C status register, which should be monitored by
software either by polling or interrupt. After that software should read I2C_STAT0 and
then I2C_STAT1 to clear ADDSEND bit. The I2C begins to receive data to I2C bus as
soon as ADDSEND bit is cleared.
Summary of Contents for GD32F20 Series
Page 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Page 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Page 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Page 385: ...GD32F20x User Manual 385 ...
Page 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...