Calcul CRC-16 - WXT530

Série WXT530 Guide de l’utilisateur

Document code
M211840FR
Revision
F
Language
Français
Product
WXT530
Document type
Guide de l'utilisateur

Le calcul du CRC est effectué sur la réponse de données avant que la parité soit ajoutée. Toutes les opérations sont censées correspondre à des nombres entiers non signés de 16 bits. Le bit le moins important se trouve à droite. Les nombres précédés par « 0x » sont au format hexadécimal. Tous les décalages se décalent sur un zéro. L'algorithme est le suivant :


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