GD32VF103 User Manual
358
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 responses
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 support both 7-bit and 10-bit address modes.
An I2C master always initiates or end a transfer using START or STOP condition and it
’
s also
responsible for SCL clock generation.
Figure 17-6. I2C communication flow with 7-bit address
Start
Slave address
W(0)
ACK
DATA0
ACK
DATAN
ACK/NACK
Stop
………………
data transfer (N+1 bytes)
From master to slave
From slave to master
R(1)
DATA0
ACK
DATAN
NACK
Figure 17-7. I2C communication flow with 10-bit address (Master Transmit)
Start
Slave address byte2
W(0)
ACK
DATA0
ACK
DATAN
ACK
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 17-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
17.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 signal to permit that transfer. At
that time, any device addressed is considered as 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.
Master Receiver.
Slave Transmitter.
Slave Receiver.
I2C block supports all of the four I2C modes. After system reset, it works in slave mode. If it
’
s