GD32VF103 User Manual
368
filled with the next transmit data. When the RBNE and BTC bit of a receiver is set, the receiver
stretches the SCL line low until the data in the transfer buffer is read out.
When works in slave mode, the SCL line stretching function can be disabled by setting the
SS bit in the I2C_CTL0 register. If this bit is set, the software is required to be quick enough
to serve the TBE, RBNE and BTC status, otherwise, overflow or underflow situation might
occur.
17.3.9.
Use DMA for data transfer
As is shown in Programming Model, each time TBE or RBNE is asserted, software should
write or read a byte, this may cause CPU
’
s high overload. The DMA controller can be used to
process TBE and RBNE flag: each time TBE or RBNE is asserted, DMA controller does a
read or write operation automatically.
The DMA request is enabled by the DMAON bit in the I2C_CTL1 register. This bit should be
set after clearing the ADDSEND status. If the SCL line stretching function is disabled for a
slave device, the DMAON bit should be set before the ADDSEND event.
Refer to the specification of the DMA controller for the configuration method of a DMA stream.
The DMA controller must be configured and enabled before I2C transfer. When the configured
number of byte has been transferred, the DMA controller generates End of Transfer (EOT)
interrupt.
When a master receives two or more bytes, the DMALST bit in the I2C_CTL1 register should
be set. The I2C master will not send NACK after the last byte. The software can set the STOP
bit to generate a stop condition in the ISR of the DMA EOT interrupt.
When a master receives only one byte, the ACKEN bit must be cleared before clearing the
ADDSEND status. Software can set the STOP bit to generate a stop condition after clearing
the ADDSEND status, or in the ISR of the DMA EOT interrupt.
17.3.10.
Packet error checking
There is a CRC-8 calculator in I2C block to perform Packet Error Checking for I2C data. The
polynomial of the CRC is x8 + x2 + x + 1 which is compatible with the SMBus protocol. If
enabled by setting PECEN bit, the PEC will calculate all the data transmitted through I2C
including address. I2C is able to send out the PEC value after the last data byte or check the
received PEC value with its calculated PEC using the PECTRANS bit. In DMA mode, the I2C
will send or check PEC value automatically if PECEN bit and PECTRANS bit is set.
17.3.11.
SMBus support
The System Management Bus (abbreviated to SMBus or SMB) is a single-ended simple two-
wire bus for the purpose of lightweight communication. Most commonly it is found in computer
motherboards for communication with power source for ON/OFF instructions.It is derived from