GD32W51x User Manual
682
TRANS=0 to ensure the ongoing transfer completes.
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.
Quad-SPI mode
Before leaving quad wire mode or disabling SPI, software should first check that TBE bit is
set and TRANS bit is cleared, then the QMOD bit in SPI_QCTL register and SPIEN bit in
SPI_CTL0 register are cleared.
20.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.
20.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