The following steps illustrate how to properly configure the CRC.
- 1.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.
- 2.If desired, seed a starting CRC value into the CRCACC registers.
- 3.Program the CRCXOR registers with the desired generator polynomial.
- 4.Program the DLENbits with the length of the data word - 1 (refer to Figure 1). This determines how many times the shifter will shift into the accumulator for each
data word.
- 5.Program the PLEN bits
with the length of the polynomial -2 (refer to Figure 1).
- 6.Determine whether shifting in trailing zeros is desired and set
the ACCM
bit accordingly.
- 7.Likewise, determine whether the MSb or LSb should be shifted
first and write the SHIFTM bit accordingly.
- 8.Set the GO bit to
begin the shifting process.
- 9.If manual SFR entry is used, monitor the FULL bit. When FULL = 0, another word of data can be written to the CRCDAT registers, keeping in mind that Most Significant Byte,
CRCDATH, should be written first if the data has more than eight bits, as the shifter
will begin upon the CRCDATL register being written.
- 10.If the scanner is used, the scanner will automatically stuff
words into the CRCDAT registers as needed, as long as the SCANGO bit is
set.
- 11.If using the Flash memory scanner, monitor the PIRx SCANIF bit
(or the SCANGO bit) for the scanner to finish pushing information into the CRCDATA
registers. After the scanner is completed, monitor the BUSY bit to
determine that the CRC has been completed and the check value can be read from the
CRCACC registers. If 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.
- 12.If manual entry is used, monitor the BUSY bit to determine when
the CRCACC registers hold the valid check value.