13.7 Configuring the CRC
The following steps illustrate how to properly configure the CRC:
- Determine if the automatic program memory scan will be used with the scanner or manual calculation through the SFR interface and perform the actions specified in CRC Data Sources, depending on which decision was made.
- If desired, seed a starting CRC value into the CRCACC registers.
- Program the CRCXOR registers with the desired generator polynomial.
- Program the DLEN bits with the length of the data word - 1 (refer to Figure 13-1). This 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 - 2 (refer to Figure 13-1).
- Determine whether shifting in trailing zeros is desired and set the ACCM bit accordingly.
- Likewise, determine whether the MSb or LSb first shifting is desired and write the SHIFTM bit accordingly.
- Set the GO bit to begin the shifting process.
- If manual SFR entry is used, monitor the FULL bit.
- When FULL =
0
, another word of data can be written to the CRCDATA registers, keeping in mind that the Most Significant Byte (CRCDATH) must be written first if the data has more than eight bits, as the shifter will begin upon the CRCDATL register being written. - If the scanner is used, the scanner will automatically load words into the CRCDATA registers as needed, as long as the GO bit is set.
- When FULL =
- If using the Flash memory scanner, monitor the PIRx SCANIF
bit for the scanner to finish pushing information into the CRCDATA registers.
- After the scan is completed, monitor the SGO bit to determine that the CRC has been completed and the check value can be read from the CRCACC registers.
- When both the interrupt flags are set (or both BUSY and SCANGO bits are cleared), the completed CRC calculation can be read from the CRCACC registers.
- If manual entry is used, monitor the BUSY bit to determine when the CRCACC registers hold the valid check value.