Toho-electronics TTM200 Manuel d'utilisateur Page 23

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 51
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 22
23
6.7 Example of CRC-16 calculations
Following is an example of calculating CRC-16 with VisualBasic6.0.
Variables are declared as shown below.
VisualBasic6.0 cannot use code-free variables. It therefore uses code-equipped 16-bit integer
variables as data. Similarly, the CRC calculation results are entered into code-equipped 32-bit
integer variables.
Dim CRC As Long
Dim i, j, arry_count As Integer
Dim c_next, c_carry As LongDim crc_arry(64) As Integer
Then enter calculable data into the crc_arry(), and enter the number of data items into the arry_count.
After that, run the following program to cause the calculation results to enter the CRC.
i = 0
CRC = 65535
For i = 0 To arry_count
c_next = crc_arry(i)
CRC = (CRC Xor c_next) And 65535
For j = 0 To 7
c_carry = CRC And 1
CRC = CRC ¥ 2
If c_carry Then
CRC = (CRC Xor &HA001) And 65535
End If
Next
Next
To affix an error code to the end of the message, affix first the low-level byte and then the high-level
byte of the CRC.
Vue de la page 22
1 2 ... 18 19 20 21 22 23 24 25 26 27 28 ... 50 51

Commentaires sur ces manuels

Pas de commentaire