EasyManua.ls Logo

TECO A510s - CRC Calculate Program (C Language)

TECO A510s
519 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
4-332
CRC calculate program (C language):
UWORD ch_sum (UBYTE long, UBYTE *rxdbuff )
{
BYTE i = 0;
UWORD wkg = 0xFFFF;
while ( long-- ) {
wkg ^= rxdbuff++;
for ( i = 0 ; i < 8; i++ ) {
if ( wkg & 0x0001 ) {
wkg = ( wkg >> 1 ) ^ 0xa001;
}
else {
wkg = wkg >> 1;
}
}
}
return( wkg );
}
ASCII Mode
RTU Mode
STX ‘:’ Node Address 02H
Address
‘0’ Function 83H
‘1’ Exception code 52H
Function
‘8’
CRC-16
High C0H
‘6’ Low CDH
Exception
code
‘5’
‘1’
LRC Check
‘2’
‘8’
END
‘CR’
‘LF’
During a communication error the drive will response with an Exception Code and send a
message back to the main system consisting of a Function Code that is “ANDED (and 80h)” with
80 Hex.
Exception code Content
01 Function code error
02 Register number error
03 DATA setting error
04
Register number is over 32

Table of Contents

Related product manuals