
12
of the system. Check node uses 16-bits cyclic redundancy.
3.1.3
错误检测的方法
3.1.3 Check mode
错误校验(
CRC
)域占用两个字节,包含了一个
16
位的二进制值。
CRC
值有传输设备计算出来,然后附加
到数据帧上,接收设备在接收数据时重新计算
CRC
值,然后与就收到的
CRC
域中的值进行比较,如果这两个值
不相等,就发生了错误。
CRC occupies 2 bytes, and it contains a binary value of 16 bits. It is got by the transmission equipment, and than it
is added in the data frame. The master will recalculate the CRC value, and then it compares the value to that received. If
2 values is not same, there must be error.
CRC
运算时,首先将一个
16
位的寄存器预置为全
1
,然后连续把数据帧中的每个字节中的
8
位与该寄存器
的当前值进行运算,仅仅每个字节的
8
个数据位参与生成
CRC
,起始位和终止位以及可能使用的奇偶位都不影
响
CRC
。在生成
CRC
时,每个字节的
8
位与寄存器中的内容进行异或,然后将结果向低位移位,高位则用
0
补
充,最低位(
LSB
)移出并检测,如果是
1
,该寄存器就与一个预设的固定值(
0A001H
)进行一次异或运算,如
果最低位为
0
,则不作任何处理。
The CRC algorithm, you will preset a 16-bit register all to 1, then each byte in the data frame of eight consecutive
operation with the current value of the register, only 8 bits of each byte in generate CRC, start bit and stop bit and the
possibility of using parity bit does not affect the CRC. When generate CRC, each byte of eight different XOR with the
contents of the registers, then the results to the low displacement, high use 0, lowest (LSB) removed and test, if it is 1,
the register is fixed with a preset value (0A001H) for an XOR operation, if the lowest is 0, do not make any processing.
上述处理重复进行,直到执行完了
8
次移位操作,当最后一位(第
8
位)移位完成以后,下一个
8
位字节与
寄存器的当前值进行异或运算,同样进行上述的另一个
8
次移位异或操作,当数据帧中的所有字节都作了处理,
生成的最终值就是
CRC
值。
The above process repeated, until the end of the eight times perform shift operation, when the last one (eighth) after
the completion of the shift, an 8-bit bytes and register under the current value of XOR operation, another eight times for
the same shift XOR operation, when all the bytes of a data frame processing, generate the final value is CRC value.
生成一个
CRC
的流程为:
The process of generating a CRC is:
1
、
预置一个
16
位寄存器为
0FFFFH
(全
1
),称之为
CRC
寄存器。
1
、
Preset a 16-bit register to be 0FFFFH (all 1), which is called CRC register.
2
、
把数据帧的第一个字节的
8
位与
CRC
寄存器中的低字节进行异或运算,结果存回
CRC
寄存器。
2
、
XORing the 8 bits of the first byte of the data frame with the low byte in the CRC register, and the result is saved
back to the CRC register.
3
、
将
CRC
寄存器向右移一位,最高位填以
0
,最低位移出并检测。
3
、
Move the CRC register to the right one, the highest position is 0, and the minimum displacement is detected.
4
、如果最低位为
0
:重复第三步(下一次移位);
如果最低位为
1
:将
CRC
寄存器与一个预设的固定值(
0A001H
)
进行异或运算。
4
、
If the lowest level is 0: repeat step 3 (the next shift);If the lowest level is 1: the CRC register is XORed with a
preset fixed value (0A001H).
5
、
重复第三步和第四步直到
8
次移位。这样处理完了一个完整的
8
位。
5
、
Repeat step 3 and step 4 up to 8 shifts. This completes a complete 8 bit.
6
、
重复第
2
步到第
5
步来处理下一个
8
位,直到所有的字节处理结束。
6
、
Repeat step 2 to step 5 to handle the next 8 bit, knowing that all byte processing ends.
7
、
最终
CRC
寄存器的值就是
CRC
的值。
7
、
The value of the final CRC register is the value of CRC.
此外,还有一种利用预设的表格计算
CRC
的方法,它的主要特点是计算速度快,但是表格需要较大的存储
空间,该方法此处不再赘述,请参阅相关资料。
Содержание ARTM
Страница 12: ...8 2 3 4 用户编程流程图 2 3 4 The Programming chart ...
Страница 13: ...9 ...