Microchip Technology MA240017 Data Sheet

Page of 278
 2008-2011 Microchip Technology Inc.
DS39927C-page 167
PIC24F16KA102 FAMILY
20.0
PROGRAMMABLE CYCLIC 
REDUNDANCY CHECK (CRC) 
GENERATOR
The programmable Cyclic Redundancy Check (CRC)
module in PIC24F devices is a software-configurable
CRC checksum generator. The CRC algorithm treats a
message as a binary bit stream and divides it by a fixed
binary number.
The remainder from this division is considered the
checksum. As in division, the CRC calculation is also
an iterative process. The only difference is that these
operations are done on modulo arithmetic based on
mod2. For example, division is replaced with the XOR
operation (i.e., subtraction without carry). The CRC
algorithm uses the term, polynomial, to perform all of
its calculations.
The divisor, dividend and remainder that are
represented by numbers are termed as polynomials
with binary coefficients.
The programmable CRC generator offers the following
features:
• User-programmable polynomial CRC equation
• Interrupt output
• Data FIFO
The module implements a software-configurable CRC
generator. The terms of the polynomial and its length
can be programmed using the CRCXOR (X<15:1>) bits
and the CRCCON (PLEN<3:0>) bits, respectively.
Consider the CRC equation:
EQUATION 20-1:
CRC
To program this polynomial into the CRC generator, the
CRC register bits should be set as provided in
TABLE 20-1:
EXAMPLE CRC SETUP
The value of X<15:1>, the 12
th
 bit and the 5
th
 bit are set
to ‘1’, as required by the equation. The 0 bit required by
the equation is always XORed. For a 16-bit polynomial,
the 16
th
 bit is also always assumed to be XORed;
therefore, the X<15:1> bits do not have the 0 bit or the
16
th
 bit.
The topology of a standard CRC generator is displayed
in 
.
FIGURE 20-1:
CRC SHIFTER DETAILS   
Note:
This data sheet summarizes the features of
this group of PIC24F devices. It is not
intended to be a comprehensive reference
source. For more information on Program-
mable Cyclic Redundancy Check, refer to
the  “PIC24F Family Reference Manual”,
Section 30. “Programmable Cyclic
Redundancy Check (CRC)”
 (DS39714).
Bit Name
Bit Value
PLEN<3:0>
1111
X<15:1>
000100000010000
x
16
 + x
12
 + x
5
 + 1
IN
OUT
BIT 0
0
1
clk
X1
IN
OUT
BIT 1
0
1
clk
X2
IN
OUT
BIT 2
0
1
clk
X3
IN
OUT
BIT 15
0
1
clk
X15
XOR
D
OUT
0
1
2
15
PLEN<3:0>
Hold
Hold
Hold
Hold
CRC Read Bus
CRC Write Bus
CRC Shift Register