Initialization and Configuration
844
SLAU723A – October 2017 – Revised October 2018
Copyright © 2017–2018, Texas Instruments Incorporated
Cyclical Redundancy Check (CRC)
Because CRC is a division on a long stream of bits, the application must take into consideration the bit
order. When processing message data that is read out by words, bit order is not an issue. For example, if
the data value in the message is 0x12345678, the most significant eight byte is 0x12 (00010010 in binary).
If the data is processed as bytes, 0x12, 0x34, 0x56, and 0x78 are copied into memory in that order and
the word is stored as 0x78563412, where 0x12 is written as byte 0, 0x34 is written as byte 1, and so on.
13.2.1.3 Endian Configuration
The following endian configuration is provided by the ENDIAN field in the CRCCTRL register:
•
Swap byte in half-word
•
Swap half word
Input data width is four bytes, hence the configuration only affects the four-byte word.
lists the
configurations that the ENDIAN bit field supports, assuming the input word is {B3, B2, B1, B0}.
Table 13-1. Endian Configuration
ENDIAN
Encoding
Definition
Configuration
0x0
Configuration unchanged.
{B3, B2, B1, B0}
0x1
Bytes are swapped in half-words but half-words are not swapped.
{B2, B3, B0, B1}
0x2
Half-words are swapped but bytes are not swapped in half-word.
{B1, B0, B3, B2}
0x3
Bytes are swapped in half-words and half-words are swapped.
{B0, B1, B2, B3}
Bit reversal is supported by the BR bit in the CRCCTRL register. The bit reversal operation works in
tandem with endian control. For example, the above table with the BR option set would look like this:
Table 13-2. Endian Configuration With Bit Reversal
ENDIAN
Encoding
Initial Endian Configuration
Configuration With Bit Reversal
(BR = 1)
0x0
Configuration unchanged.
{B3[31:24], B2[23:16], B1[15:8], B0[7:0]}
B3[24:31],B2[16:23],B1[8:15],B0[0:7]
0x1
Bytes are swapped in half-words but half-words are not swapped.
{B2[23:16], B3[31:24], B0[7:0], B1[15:8]}
B2[16:23],B3[24:31],B0[0:7],B1[8:15]
0x2
Half-words are swapped but bytes are not swapped in half-word.
{B1[15:8], B0[7:0], B3[31:24], B2[23:16]}
B1[8:15],B0[0:7],B3[24:31],B2[16:23]
0x3
Bytes are swapped in half-words and half-words are swapped.
{B0[7:0], B1[15:8], B2[23:16], B3[31:24]}
B0[0:7],B1[8:15],B2[16:23],B3[24:31]
13.3 Initialization and Configuration
The following describes the initialization and configuration procedures of the CRC module.
13.3.1 CRC Initialization and Configuration
The CRC engine works in push through mode, which means it works on streaming data. This section
describes the steps for initializing the CRC module:
1. Enable the CRC by setting the R0 bit in the CRC and Cryptographic Module s (RCGCCM) register,
System Control offset 0x674.
2. Configure the desired CRC data size, bit order, endian configuration and CRC type by programming
the CRC Control (CRCCTRL) register, offset 0x400.
3. If the CRC value has not been initialized to all 0s or all 1s using the INIT field in the CRCCTRL
register, program the initial value in the CRC SEED/Context (CRCSEED) register, offset 0x410.
4. Repeatedly write the DATAIN field in the CRC Data Input (CRCDIN) register, offset 0x414. If the SIZE
bit in the CRCCTRL register is set to select byte, the CRC engine operates in byte mode and only the
least significant byte is used for CRC calculation.