Вычисление CRC-16 - WXT530

Серия WXT530 Руководство пользователя

Document code
M211840RU
Revision
F
Language
Русский
Product
WXT530
Document type
Руководство пользователя

Вычисление CRC ответных данных выполняется до добавления бита четности. Все операции выполняются с 16-битовыми целыми числами без знака. Наименее значимый бит — правый. Числа после 0x шестнадцатеричные. При сдвиге свободные биты заменяются нулями. Алгоритм расчета:


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
    }
  }
}