- CRC8-CCITT and CRC16-CCITT schemes are implemented in the SPI module
independently for transmit and receive operations.
- CRC functionality shall be enabled by application when SPI frame size is only
8-bits or 16-bits.
- This is a software guideline and no specific check is done in hardware based on
frame size configuration.
- For 8-bit transfers, CRC8 or CRC16 schemes can be selected by application.
- For 16-bit transfers, CRC16 scheme has to be selected.
- The CRC on TX and RX paths are always active and there is no need to enable CRC
functionality explicitly in software.
Transmitter side operation (CRC8/CR16) :
- The TX CRC block is logically located between the SPI.TXDATA register and TXFIFO
in the design.
- Select CRC polynomial (8 or 16) based on SPI data frame size (selection applies
to both TX and RX CRC units).
- TX side CRC state register resets to the seed value of 0xFF or 0xFFFF.
- When the bus controller (CPU or µDMA) writes data into SPI.TXDATA register, the
data is written into the TXFIFO and at the same time used to update the
SPI.TXCRC register by hardware logic.
- Data from TXFIFO gets loaded into shift register and transmitted out.
- After the required amount of data has been written into SPI.TXDATA register, the
software has to read the SPI.TXCRC state register.
- Software must write the obtained CRC checksum into the SPI.TXDATA register for
transmission.
- Initialize SPI.TXCRC state register and repeat this sequence for every block of
SPI data transmission.
Receiver side operation (CRC8/CRC16) :
- The RX CRC block is logically located between RXDATA and RXFIFO in the design.
- Select CRC polynomial (8 or 16) based on the SPI data frame size (selection
applies to both TX and RX CRC units).
- The RX side CRC state register resets to the seed value of 0xFF or 0xFFFF.
- Data is received into shift register and gets loaded into RXFIFO during receive
operation.
- When the bus controller (CPU or µDMA) reads data from the SPI.RXDATA register,
the data is returned from RXFIFO and at the same time used to update the
SPI.RXCRC state register by hardware logic.
- After the required amount of data have been read from SPI.RXDATA, software can
either:
- Read out the received checksum and then check the SPI.RXCRC state which
is zero if there are no errors
- Read out the SPI.RXCRC state and then read out the checksum through
SPI.RXDATA and compare the two values
- Initialize SPI.RXCRC state register and repeat this sequence for every block of
SPI data reception.
In case SPI functionality is not being used, the CRC engine can be used as a
general-purpose CRC generator.
CTL0.GPCRCEN register bit can be set to enable this functionality. The transmit side
CRC can then be used by application software when SPI enable is zero.