CRC-16 计算 - WXT530

WXT530 系列 用户指南

Document code
M211840ZH
Revision
F
Language
中文 (大陆)
Product
WXT530
Document type
用户指南

在添加奇偶性之前对数据响应执行 CRC 的计算。假定所有操作都是要对 16 位无符号整数执行的。最低有效位位于右侧。以 0x 为前缀的数字为十六进制。所有移位均用一个 0 来进行移位。该算法为:


Initialize the CRC to zero. For each character beginning with the address, up to but not including the carriage return (<cr>), do as follows:
{
  Set the CRC equal to the exclusive OR of the character and itself
  for count =1 to 8
  {
    if the least significant bit of the CRC is one
    {
        right shift the CRC one bit set
        CRC equal to the exclusive OR of 0xA001 and
        itself
    }
    else
    {
      right shift the CRC one bit
    }
  }
}