GD32F20x User Manual
521
20.3.6.
I2C communication flow
Each I2C device is recognized by a unique address (whether it is a microcontroller, LCD driver,
memory or keyboard interface) and can operate as either a transmitter or receiver, depending
on the function of the device.
An I2C slave will continue to detect addresses after a START condition on I2C bus and
compare the detected address with its slave address which is programmable by software.
Once the two addresses match, the I2C slave will send an ACK to the I2C bus and response
to the following command on I2C bus: transmitting or receiving the desired data. Additionally,
if General Call is enabled by software, the I2C slave always responses to a General Call
Address (0x00). The I2C block supports both 7-bit and 10-bit address modes.
An I2C master always initiates or ends a transfer using START or STOP
condition and it’s
also responsible for SCL clock generation.
Figure 20-6. I2C communication flow with 7-bit address
Start
Slave address
R(1)
ACK
DATA0
ACK
DATAN
ACK/NACK
Stop
……
data transfer (N+1 bytes)
From master to slave
From slave to master
W(0)
DATA0
ACK
DATAN
NACK
Figure 20-7. I2C communication flow with 10-bit address (Master Transmit)
Start
Slave address byte2
W(0)
ACK
DATA0
ACK
DATAN
ACK/
NACK
Stop
……
data transfer (N+1 bytes)
From master to slave
From slave to master
Slave address byte1
(hreader)
ACK
1 1 1 1 0 x x
write
Figure 20-8. I2C communication flow with 10-bit address (Master Receive)
Start
Slave address
byte2
W(0)
ACK
DATA0
ACK
DATAN
NACK
Stop
……
data transfer (N+1 bytes)
From master to slave
From slave to master
Slave address byte1
(hreader)
ACK
1 1 1 1 0 x x
write
ACK
Slave address
byte1 (hreader)
Start
R(1)
read
20.3.7.
Programming model
An I2C device such as LCD driver may only be a receiver, whereas a memory can both
receive and transmit data. In addition to transmitters and receivers, devices can also be
considered as masters or slaves when performing data transfers. A master is the device which
initiates a data transfer on the bus and generates the clock signals to permit that transfer. At
that time,any device addressed is considered a slave.
An I2C device is able to transmit or receive data whether it’s a master or a slave, thus, there’re
4 operation modes for an I2C device:
Master Transmitter
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 ...