![GigaDevice Semiconductor GD32E23 Series User Manual Download Page 480](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32e23-series/gd32e23-series_user-manual_2225794480.webp)
GD32E23x User Manual
480
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 to be high overloaded. The DMA controller can be
used to process TBE and RBNE flags: each time TBE or RBNE is asserted, DMA controller
does a read or write operation automatically. It reduces the load on the CPU. See the DMA
section for details on how to configure DMA.
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 the I2C transfer. When the
configured number of bytes have been transferred, the DMA controller generates End of
Transfer (EOT) interrupt.
DMA will send an End of Transmission (EOT) signal to the I2C
interface and generates a DMA full transfer finish interrupt.
When a master receives two or more bytes, the DMALST bit in the I2C_CTL1 register should
be set. The I2C master will send NACK after the last byte. The STOP bit can be set by
software to generate a STOP signal in the ISR of the DMA full transfer finish 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 signal after clearing
the ADDSEND status, or in the ISR of the DMA full transfer finish interrupt.
17.3.10.
Packet error checking
There is a CRC-8 calculator in I2C block to perform PEC (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
are 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