Rev. 1.10
134
November 04, 2019
Rev. 1.10
135
November 04, 2019
HT45F5Q-3
Battery Charger Flash MCU
HT45F5Q-3
Battery Charger Flash MCU
CRC Calculation Procedures
1. Clear the checksum register pair, CRCDH and CRCDL.
2.
Execute an “Exclusive OR” operation with the 8-bit input data byte and the 16-bit CRCSUM high
byte. The result is called the temporary CRCSUM.
3. Shift the temporary CRCSUM value left by one bit and move a “0” into the LSB.
4. Check the shifted temporary CRCSUM value after procedure 3.
If the MSB is 0, then this shifted temporary CRCSUM will be considered as a new temporary
CRCSUM.
Otherwise, execute an “Exclusive OR” operation with the shifted temporary CRCSUM
in procedure 3 and a data “8005H”. Then the operation result will be regarded as the new
temporary CRCSUM.
Note that the data to be perform an “Exclusive OR” operation is “8005H” for the CRC-16
polynomial while for the CRC-CCITT polynomial the data is “1021H”.
5.
Repeat the procedure 3 ~ procedure 4 until all bits of the input data byte are completely calculated.
6.
Repeat the procedure 2 ~ procedure 5 until all of the input data bytes are completely calculated.
Then, the latest calculated result is the final CRC checksum, CRCSUM.
CRC Calculation Examples
•
Write 1 byte input data into the CRCIN register and the corresponding CRC checksum are
individually calculated as the following table shown.
CRC Data Input
CRC Polynomial
00H
01H
02H
03H
04H
05H
06H
07H
CRC-CCITT (X
16
+X
12
+X
5
+1)
0000H 1021H 2042H 3063H 4084H 50A5H 60C6H 70E7H
CRC-16 (X
16
+X
15
+X
2
+1)
0000H 8005H 800FH 000AH 801BH 001EH 0014H 8011H
Note: The initial value of the CRC checksum register pair, CRCDH and CRCDL, is zero before each
CRC input data is written into the CRCIN register.
•
Write 4 bytes input data into the CRCIN register sequentially and the CRC checksum are
sequentially listed in the following table.
CRC Data Input
CRC Polynomial
CRCIN =
78H→56H→34H→12H
CRC-CCITT (X
16
+X
12
+X
5
+1)
(CRCDH, CRCDL) = FF9F
H→BBC3H→A367H→D0FAH
CRC-16 (X
16
+X
15
+X
2
+1)
(CRCDH, CRCDL) = 0110h→91F1h→F2DEh→5C43h
Note: The initial value of the CRC checksum register pair, CRCDH and CRCDL, is zero before the
sequential CRC data input operation.
Program Memory CRC Checksum Calculation Example
1. Clear the checksum register pair, CRCDH and CRCDL.
2.
Select the CRC-CCITT or CRC-16 polynomial as the generating polynomial using the POLY bit
in the CRCCR register.
3. Execute the table read instruction to read the program memory data value.
4. Write the table data low byte into the CRCIN register and execute the CRC calculation with the
current CRCSUM value. Then a new CRCSUM result will be obtained and stored in the CRC
checksum register pair, CRCDH and CRCDL.
5.
Write the table data high byte into the CRCIN register and execute the CRC calculation with the
current CRCSUM value. Then a new CRCSUM result will be obtained and stored in the CRC
checksum register pair, CRCDH and CRCDL.
6.
Repeat the procedure 3 ~ procedure 5 to read the next program memory data value and execute
the CRC calculation until all program memory data are read followed by the sequential CRC
calculation. Then the value in the CRC checksum register pair is the final CRC calculation result.