GD32F20x User Manual
527
Figure 20-11. Programming model for master transmitting
IDLE
Master generates START
condition
Master sends Address
Slave sends Acknowledge
Master sends Header
Slave sends Acknowledge
SCL stretched by master
Master sends DATA(1)
Slave sends Acknowledge
……
(
Data transmission
)
Master sends DATA(N-2)
Slave sends Acknowledge
Master sends DATA(N)
Slave sends Acknowledge
Master generates STOP
condition
1) Software initialization
Set ADD10SEND
4) Clear ADD10SEND
Set ADDSEND
4) Clear ADDSEND
Set TBE
Set TBE
Set TBE
Set BTC
5) Write DATA(1) to TRB
Write DATA(x) to TRB
Set TBE
6) Write DATA(2) to TRB
7) Write DATA(3) to TRB
8)Write DATA(N) to TRB
Master sends DATA(N-1)
Slave sends Acknowledge
Set TBE
9) Set STOP
I2C Line State
Hardware Action
Software Flow
2) Set START
Set SBSEND
SCL stretched by master
3) Clear SBSEND
SCL stretched by master
SCL stretched by master
Programming model in master receiving mode
In master receiving mode, a master is responsible for generating NACK for the last byte
reception and then sending STOP condition on I2C bus. So, special attention should be paid
to ensure the correct ending of data reception. Two solutions for master receiving are provided
here for your application: Solution A and B. Solution A requires the software’s quick response
to I2C events, while Solution B doesn’t.
Solution A
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.
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 ...