![](http://datasheet.mmic.net.cn/30000/M30622F8PGP_datasheet_2359050/M30622F8PGP_209.png)
CRC Calculation
209
Mitsubishi microcomputers
M16C / 62P Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Under
development
Preliminary Specifications Rev.1.0
Specifications in this manual are tentative and subject to change.
(2) Write 000016 (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 “80C416”
(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
(1) Reverse the bit positions of the value “80C416” bytewise in a program.
(3) Write 0116
b0
b7
b15
b0
CRCIN register
CRCD register
118916
Two cycles later, the CRC code for “8016,” i.e.,
918816, has its bit positions reversed to become
“118916” which is stored in the CRCD register.
(c) Details of CRC operation
In the case of (3) above, the value written to the CRCIN register “0116 (000000012)” has its bit positions reversed to
become “100000002.” The value “1000 0000 0000 0000 0000 00002” derived from that by adding 16 digits and the
CRCD register’s initial value “000016” are added, the result of which is divided by the generator polynomial using
modulo-2 arithmetic.
The value “0001 0001 1000 10012 (118916)” derived from the remainder “1001 0001 1000 10002 (918816)” 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 “2316 (001000112)” has its bit
positions reversed to become “110001002. The value “1100 0100 0000 0000 0000 00002” derived from that by adding
16 digits and the remainder in (3) “1001 0001 1000 10002” 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 00012 (0A4116)” derived from the remainder by reversing its bit positions may be read
from the CRCD register.
(b) Setting procedure
Generator polynomial: X16 + X12 + X5 + 1 (1 0001 0000 0010 00012)
“8016”
“0116”, “C416”
“2316”
→
(4) Write 2316
b0
b7
b15
b0
0A4116
CRCIN register
CRCD register
Two cycles later, the CRC code for “80C416,” i.e.,
825016, has its bit positions reversed to become
“0A4116” which is stored in the CRCD register.
Figure 1.24.3. CRC Calculation