English
Language : 

PIC18LF24K Datasheet, PDF (160/594 Pages) –
PIC18(L)F26/45/46K40
13.4 CRC Polynomial Implementation
Any polynomial can be used. The polynomial and
accumulator sizes are determined by the PLEN<3:0>
bits. For an n-bit accumulator, PLEN = n-1 and the
corresponding polynomial is n+1 bits. Therefore, the
accumulator can be any size up to 16 bits with a
corresponding polynomial up to 17 bits. The MSb and
LSb of the polynomial are always ‘1’ which is forced by
hardware. All polynomial bits between the MSb and
LSb are specified by the CRCXOR registers. For
example, when using CRC16-ANSI, the polynomial is
defined as X16+X15+X2+1. The X16 and X0 = 1 terms
are the MSb and LSb controlled by hardware. The X15
and X2 terms are specified by setting the
EXAMPLE 13-2: CRC LFSR EXAMPLE
corresponding CRCXOR<15:0> bits with the value of
0x8004. The actual value is 0x8005 because the
hardware sets the LSb to 1. However, the LSb of the
CRCXORL register is unimplemented and always
reads as ‘0’. Refer to Example 13-1.
Data in
b15
Linear Feedback Shift Register for CRC-16-ANSI
x16 + x15 + x2 + 1
Augmentation Mode ON
b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2
Rev. 10-000207A
5/27/2014
b1 b0
Augmentation Mode OFF
b15
b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2
Data in
b1 b0
13.5 CRC Data Sources
Data can be input to the CRC module in two ways:
- User data using the CRCDATA registers
(CRCDATH and CRCDATL)
- Flash using the Program Memory Scanner
To set the number of bits of data, up to 16 bits, the
DLEN bits of CRCCON1 must be set accordingly. Only
data bits in CRCDATA registers up to DLEN will be
used, other data bits in CRCDATA registers will be
ignored.
Data is moved into the CRCSHIFT as an intermediate
to calculate the check value located in the CRCACC
registers.
The SHIFTM bit is used to determine the bit order of the
data being shifted into the accumulator. If SHIFTM is
not set, the data will be shifted in MSb first (Big Endian).
The value of DLEN will determine the MSb. If SHIFTM
bit is set, the data will be shifted into the accumulator in
reversed order, LSb first (Little Endian).
The CRC module can be seeded with an initial value by
setting the CRCACC<15:0> registers to the
appropriate value before beginning the CRC.
13.5.1 CRC FROM USER DATA
To use the CRC module on data input from the user, the
user must write the data to the CRCDAT registers. The
data from the CRCDAT registers will be latched into the
shift registers on any write to the CRCDATL register.
13.5.2 CRC FROM FLASH
To use the CRC module on data located in Flash
memory, the user can initialize the Program Memory
Scanner as defined in Section 13.9, Program Memory
Scan Configuration.
 2016 Microchip Technology Inc.
Preliminary
DS40001816C-page 160