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 DLEN bits 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 first shifting is
desired, 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.
- 9.1.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.
- 9.2.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.
- 10.If using the Flash memory scanner, monitor the PIRx SCANIF
bit for the scanner to finish pushing information into the CRCDATA registers.
- 10.1.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.
- 10.2.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.
- 11.If manual entry is used, monitor the BUSY bit to determine
when the CRCACC registers hold the valid check value.