MEM.CRC16_generic (FUN)

This function of the CAA_Memory.library calculates the check sum of a memory area in a generalized manner.

Input:

pMemoryBlock

DWORD

Address of memory area

uiLength

UINT

Size of area in bytes

wCRCInit

WORD

Initial value of check sum

wPoly

WORD

Polynomial of CRC algorithm

xReflectInput

BOOL

Reflect input bytes

xReflectOutput

BOOL

Reflect output bytes

wXORout

WORD

XOR Word preceeding output

Output:

MEM.CRC16_CCITT

WORD

check sum

Example:

sTest : STRING(10) := '123456789' ;

->

MEM.CRC16_generic(ADR(sTest),9,16#1021, FALSE, FALSE, 16#0000) = 16#29B1

Typical input parameters:

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