
19. CRC Calculation
Figure 19.3
CRC Calculation
CRC Calculation for M32C
CRC Calculation and Setup Procedure to Generate CRC Code for 80C4h
CRC code: a remainder of division,
Generator polynomial: X16 + X12 + X5 + 1 (1 0001 0000 0010 0001b)
CRCD register
Setting Steps
(1) Invert a bit position of 80C4h per byte by program
80h
01h, C4h
23h
(2) Set 0000h (default value)
CRCIN register
(3) Set 01h
Bit position of the CRC code for 80h (9188h)
is inverted to 1189h, which is stored into the
CRCD register in the 3rd cycle.
(4) Set 23h
CRCD register
CRCIN register
Bit position of the CRC code for 80C4h
(8250h) is inverted to 0A41h, which is stored
into the CRCD register in the 3rd cycle.
CRCD register
Details of CRC Calculation
As shown in (3) above, bit position of 01h (00000001b) written to the CRCIN register is inverted to 10000000b.
Add 1000 0000 0000 0000 0000 0000b, as 10000000b plus 16 digits, to 0000h as the default value of the
CRCD register to perform the modulo-2 division.
1 0001 0000 0010 0001 1000 0000 0000 0000 0000 0000
0001 0001 1000 1001b (1189h), the remainder 1001 0001 1000 1000b (9188h) with inversed bit position, can be
read from the CRCD register.
When going on to (4) above, 23h (00100011b) written in the CRCIN register is inverted to 11000100b.
Add 1100 0100 0000 0000 0000 0000b plus 16 digits, to 1001 0001 1000 1000b as a remainder of (3) left in the
CRCD register to perform the modulo-2 division.
0000 1010 0100 0001b (0A41h), the remainder with inverted bit position, can be read from CRCD register.
1189h
0A41h
Generator
polynomial
1000 1000
Data
1000 1000 0001 0000 1
1000 0001 0000 1000 0
1001 0001 1000 1000
Modulo-2 Arithmetic is
calculated on the law below
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0
-1 = 1
1000 1000 0001 0000 1
CRC code
b15
b0
b15
b7
value of the CRCIN register with inversed bit position
Generator polynomial