GD32VF103 User Manual
389
TI mode
The disabling sequence of TI mode is the same as the sequences described above.
NSS pulse mode
The disabling sequence of NSSP mode is the same as the sequences described above.
18.5.4.
DMA function
The DMA frees the application from data writing and reading process during transfer, to
improve the system efficiency.
DMA function in SPI is enabled by setting DMATEN and DMAREN bits in SPI_CTL1 register.
To use DMA function, application should first correctly configure DMA modules, then
configure SPI module according to the initialization sequence, at last enable SPI.
After being enabled, if DMATEN is set, SPI will generate a DMA request each time when
TBE=1, then DMA will acknowledge to this request and write data into the SPI_DATA register
automatically. If DMAREN is set, SPI will generate a DMA request each time when RBNE=1,
then DMA will acknowledge to this request and read data from the SPI_DATA register
automatically.
18.5.5.
CRC function
There are two CRC calculators in SPI: one for transmission and the other for reception. The
CRC calculation uses the polynomial defined in SPI_CRCPOLY register.
Application can enable the CRC function by setting CRCEN bit in SPI_CTL0 register. The
CRC calculators continuously calculate CRC for each bit transmitted and received on lines,
and the calculated CRC values can be read from SPI_TCRC and SPI_RCRC registers.
To transmit the calculated CRC value, application should set the CRCNT bit in SPI_CTL0
register after the last data is written to the transmit buffer. In full-duplex mode (MFD or SFD),
when the SPI transmits a CRC and prepares to check the received CRC value, the SPI treats
the incoming data as a CRC value. In reception mode (MRB, MRU, SRU and SRB), the
application should set the CRCNT bit after the second last data frame is received. When CRC
checking fails, the CRCERR flag will be set.
If DMA function is enabled, application doesn
’t need to configure CRCNT bit and hardware
will automatically process the CRC transmitting and checking.
18.6.
SPI interrupts
18.6.1.
Status flags
Transmit buffer empty flag (TBE)