19.7 Configuring the CRC Module
The following steps illustrate how to properly configure the CRC:
- When applicable, seed a starting CRC value into the CRCOUT registers.
- Program the CRCXOR registers with the desired generator polynomial.
- Program the DLEN bits with the length of the data word (refer to Figure 19-1). This value determines how many times the shifter will shift into the accumulator for each data word.
- Program the PLEN bits with the length of the polynomial (refer to Figure 19-1).
- Determine whether shifting in trailing zeroes is desired and set the ACCM bit accordingly.
- Determine whether the MSb or LSb first shifting is desired, and write the SHIFTM bit accordingly.
- Load the CRCDATA registers with the data for which the CRC value is to be calculated.
- Set the GO bit to begin the shifting process.
- When the FULL
bit =
0
, another word of data can be written to the CRCDATA registers.Important: When loading data that’s length is larger than one byte into the CRCDATA registers, the Most Significant Bytes must be loaded into the CRCDATAT/U/H registers before loading the CRCDATAL register. Shifting begins once CRCDATAL is loaded. - When the CRC calculation is complete, the CRC Interrupt Flag (CRCIF) bit is set and the BUSY bit is cleared, indicating the check value can be read from the CRCOUT registers. If the CRC Interrupt Enable (CRCIE) bit is set, an interrupt will be generated each time the CRCIF bit is set. The CRCIF bit must be cleared in software.