CRC 生成流程:
1 预置一个 16 位寄存器为 0FFFFH(全 1),
称之为
CRC
寄存器。
2
把数据帧中的第一个字节的
8
位与
CRC
寄
存器中的低字节进行异或运算,结果存回 CRC 寄存
器。
3 将 CRC 寄存器向右移一位,最高位填 0,最
低位移出并检测。
4 如果最低位移出为 0:重复第 3 步(下一次
移位);如果最低位移出为
1
:将
CRC
寄存器与一
个预设固定值(
0A001H
)进行异或运算。
5 重复第 3 步和第 4 步直到 8 次移位。这样
就处理完了一个完整的 8 位。
6 重复第 2 步到第 5 步来处理下一个 8 位,
直到所有的字节处理结束。
7
最终
CRC
寄存器的值就是
CRC
的值。
此外还有一种利用查表计算
CRC
的方法,它的
主要特点是计算速度快,但是表格需要较大的存储
空间,该方法此处不再赘述,请查阅相关资料。
CRC generation process:
1 Preset a 16-bit register to 0FFFFH (all 1s) and
call it CRC register.
2 XOR the 8 bits of the first byte in the data
frame with the low byte in the CRC register
and store the result back in the CRC register.
3 Move the CRC register one bit to the right, fill
“0” in the highest bit, and move the lowest bit
out and detect it.
4 If the shifted out minimum bit is 0: Repeat step
3 (next shift); if the shifted out minimum bit is
1: XOR the CRC register with a preset fixed
value (0A001H).
5 Repeat step 3 and 4 until 8 shifts to complete a
complete 8-bit processing.
6 Repeat step 2 to 5 to process the next 8 bits
until processing of all byte ends.
7 The final CRC register value is the CRC value.
In addition, there is a method for calculating
CRC by using a look-up table. Its main feature
is that the calculation speed is fast, but the
table needs a large storage space. This method
is not described here any more. Please refer to
related material.
读数=有效值×10
(
小数点
-3)
例:读到数据为 5000,小
数点为 2,即实际数据为
5000*10
(2-3)
=500.0
Reading = Effective value
×
10
(Decimal point -3)
For example: When the data
is read as 5000 and the
decimal point is 2, the actual
data is 5000*10(2-3) = 500.0