CRC16_generic (FUN)¶
FUNCTION CRC16_generic : WORD
Function calculates the checksum CRC16 of the “MemoryBlock” in a generalized manner.
Typical input parameter:
CRC16 standard :
wCRCInit := 16#0000
wPoly := 16#8005
xReflectInput := TRUE
xReflectOutput := TRUE
wXORout := 16#0000
CRC16-CCITT :
wCRCInit := 16#FFFF
wPoly := 16#1021
xReflectInput := FALSE
xReflectOutput := FALSE
wXORout := 16#0000
CRC16-Modbus :
wCRCInit := 16#FFFF
wPoly := 16#8005
xReflectInput := TRUE
xReflectOutput := TRUE
wXORout := 16#0000
Example:
sTest : STRING(10) := '123456789' ;
->
MEM.CRC16_generic(ADR(sTest),9,16#1021, FALSE, FALSE, 16#0000) = 16#29B1
- InOut:
- Scope - Name - Type - Comment - Return - CRC16_generic- WORD- function returns generalized CRC16 of “MemoryBlock” - Input - pMemoryBlock- POINTER TO BYTE - address of memory Block - uiLength- UINT- length of MemoryBlock in byte - wCRCInit- WORD- initial value for CRC value - wPoly- WORD- polynom value for CRC algorithm - xReflectInput- BOOL- reflect input data bytes - xReflectOutput- BOOL- reflect CRC before final XOR - wXORout- WORD- final XOR value before output 
