CRC-16-Berechnung - WXT530

Serie WXT530 Benutzerhandbuch

Document code
M211840DE
Revision
F
Language
Deutsch
Product
WXT530
Document type
Benutzerhandbuch

Die Berechnung der CRC der Datenantwort erfolgt, bevor die Parität hinzugefügt wird. Alle Operationen erfolgen mit 16-Bit-Ganzzahlen ohne Vorzeichen. Das niederwertigste Bit steht rechts. Hexadezimalzahlen wird 0x vorangestellt. Alle Bitverschiebungen erfolgen zu null. Der Algorithmus:


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