Description
This function calculates the CRC of individual bytes one at a time.Before the CRC library is included, the constant CRC_POLY must be defined. Valid values are:
const CRC_POLY = 0x1021 // CRC CCITT const CRC_POLY = 0x8408 // CRC CCITT reversed const CRC_POLY = 0x8005 // CRC16 const CRC_POLY = 0xA001 // CRC16 reversedBefore a CRC calculation is started, the CRC accumulator must be initialised to either all zeros or all ones. Using all ones gives better error detection for some zero bit sequences but since it is common practice to use all zeros as the inital value then it is recommended that all zeros be used.
e.g. const CRC_POLY = 0x1021 // CRC CCITT include "crc_lib.bas" uint acc ubyte arr[10] // init CRC acc acc = 0 for j=0 while j<10 step j+=1 do acc = CRC_byte(acc, arr[j]) done // CRC for arr is not in accDefinition
uint CRC_byte(uint acc, ubyte data)Library
LIB/crc_lib.basUsage
On entry:acc is the CRC accumulator, the CRC is calulated in this variableOn exit:
data is the byte to be included in the CRC calculationreturn 16 bit CRC