Hello cicciocb,
I currently use two CRC16 routines. One is CRC-16/IBM-3740 and the other is the CRC-16/MCRF4XX (Microchip).
Yes, it would be great if the parameters could be specified (for unisersal CRC16), e.g. Poly Init RefIn RefOut XorOut.
For me it would be ok (because of the speed) if it was a calculation and not a table.
https://crccalc.com/?crc=123456789&meth ... &outtype=0
Example :
Code: [Local Link Removed for Guests]
' CRC16-CCITT-Berechnung im Annex32 Basic, erwartetes Ergebnis 0x29B1
' Beispiel-String für die CRC-Berechnung
testString$ = "123456789"
crc = &HFFFF ' Startwert für CRC
' CRC-Wert berechnen
FOR i = 1 TO LEN(testString$)
byteVal = ASC(MID$(testString$, i, 1))
crc = (crc XOR (byteVal << 8)) ' XOR mit dem Byte, nach links verschoben
FOR j = 0 TO 7
IF (crc AND &H8000) THEN
crc = (crc << 1) XOR &H1021 ' Polynom verwenden
ELSE
crc = crc << 1
ENDIF
NEXT j
NEXT i
crc = crc AND &HFFFF ' Maskierung auf 16 Bit
' CRC-Wert mit WLOG ausgeben
WLOG "CRC16-CCITT für '" & testString$ & "' = "; HEX$(crc)
Bishopxxl
Technical Parameters of CRC-16/MCRF4XX
This CRC variant has the following parameters:
Polynomial: 0x1021 (which corresponds to the polynomial x16+x12+x5+1x16+x12+x5+1)
Initial Value: 0xFFFF
Reflection: Data is not reflected during the CRC calculation (no bit reversal).
Output XOR: No additional XOR operation is applied at the end of the calculation.
Technical Parameters of CRC-16/IBM-3740
The CRC-16/IBM-3740 variant, also known as CRC-16/ANSI or simply CRC-16, has these specific parameters:
Polynomial: 0x1021 (hexadecimal), which corresponds to the polynomial x16+x12+x5+1x16+x12+x5+1.
Initial Value: 0xFFFF.
Reflection: Neither input data nor output checksum are reflected (i.e., no bit reversal is applied).
Output XOR: No additional XOR operation is performed on the output.