CRC-16 の計算 - WXT530

WXT530 シリーズ ユーザーガイド

Document code
M211840JA
Revision
F
Language
日本語
Product
WXT530
Document type
取扱説明書

CRC の計算は、パリティを追加する前のデータ応答で実行されます。すべての演算は、16 ビットの符号なし整数で行います。最下位ビットは右側です。先頭に 0x が付いている数字は 16 進数です。シフトの結果はすべてゼロになります。アルゴリズムは、以下のとおりです。


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