
GD32F10x User Manual
469
set in transmitting mode, the transmitter stretches the SCL line low until the transfer buffer
register is filled with the next data to be transmitted. When the RBNE and BTC bits are set in
receiving mode, 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 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.
Summary of Contents for GD32F10 Series
Page 63: ...GD32F10x User Manual 63 programmed during the chip production ...
Page 117: ...GD32F10x User Manual 117 010 1 0 011 0 9 ...
Page 416: ...GD32F10x User Manual 416 shadow register updates every update event ...
Page 427: ...GD32F10x User Manual 427 value ...
Page 518: ...GD32F10x User Manual 518 These bits are not used in SPI mode ...