CRC Calculation
209
Mitsubishi microcomputers
M16C / 62P Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
development
Preliminary Specifications Rev.1.0
Specifications in this manual are tentative and subject to change.
(2) Write 0000
16
(initial value)
b15
b0
CRCD register
1 0001 0000 0010 0001
1000 0000 0000 0000 0000 0000
1000 1000 0001 0000 1
1000 0001 0000 1000 0
1000 1000 0001 0000 1
1001 0001 1000 1000
1000 1000
Generator polynomial
Data
CRC code
Modulo-2 operation is
operation that complies
with the law given below.
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0
-1 = 1
Setup procedure and CRC operation when generating CRC code
“
80C4
16
”
(a) CRC operation performed by the M16C
CRC code: Remainder of a division in which the value written to the CRCIN register with its bit positions reversed is
divided by the generator polynomial
Generator polynomial: X
16
+ X
12
+ X
5
+ 1 (1 0001 0000 0010 0001
2
)
(1) Reverse the bit positions of the value “80C4
16
” bytewise in a program.
“80
16
” “01
16
”, “C4
16
” “23
16
”
(3) Write 01
16
b0
b7
b15
b0
CRCIN register
Two cycles later, the CRC code for “80
16
,” i.e.,
9188
16
, has its bit positions reversed to become
“1189
16
” which is stored in the CRCD register.
CRCD register
1189
16
(c) Details of CRC operation
In the case of (3) above, the value written to the CRCIN register “01
16
(00000001
2
)” has its bit positions reversed to
become “10000000
2
.” The value “1000 0000 0000 0000 0000 0000
2
” derived from that by adding 16 digits and the
CRCD register’s initial value “0000
16
” are added, the result of which is divided by the generator polynomial using
modulo-2 arithmetic.
The value “0001 0001 1000 1001
2
(1189
16
)” derived from the remainder “1001 0001 1000 1000
2
(9188
16
)” by
reversing its bit positions may be read from the CRCD register.
If operation (4) above is performed subsequently, the value written to the CRCIN register “23
16
(00100011
2
)” has its bit
positions reversed to become “11000100
2
. The value “1100 0100 0000 0000 0000 0000
2
” derived from that by adding
16 digits and the remainder in (3) “1001 0001 1000 1000
2
” which is left in the CRCD register are added, the result of
which is divided by the generator polynomial using modulo-2 arithmetic.
The value “0000 1010 0100 0001
2
(0A41
16
)” derived from the remainder by reversing its bit positions may be read
from the CRCD register.
(b) Setting procedure
(4) Write 23
16
b0
b7
b15
b0
0A41
16
CRCIN register
Two cycles later, the CRC code for “80C4
16
,” i.e.,
8250
16
, has its bit positions reversed to become
“0A41
16
” which is stored in the CRCD register.
CRCD register
Figure 1.24.3. CRC Calculation