Crc Validation Routines - Kalatec Automacao STR6-RS485 User Manual

Rs485 open loop step motor drive
Table of Contents

Advertisement

6.4.3 Write multiple registers command 0x10
Host -> Slave Data
Device
address
01
Slave -> Host Data
01
Write 14464 to the slave 16bit low (register address 64) and 16bit high (register address)
65) Write 1, that is, the total number of trips is 80000pulse.

6.5 CRC Validation routines

The following routine calculates CRC using the C language.
Funct_CRC16(unsigned char
Uint16
{
Uint16
i,j,tmp;
Uint16
crcdata=0xFFFF;
for(i=0;i<DataLen;i++)
{
crcdata=(*puchMsg)^crcdata;
puchMsg++; for(j=0;j<8;j++)
{
tmp=crcdata&0x0001;
crcdata=crcdata>>1;
if(tmp){
crcdata=crcdata^0xA0
01;
}
} }
returncrcdata;
}
Function
The
code
starting
address
10
00
44
Function
The starting
code
address
10
00
* puchMsg,
The
Write
Write
number
content
the
of
number
bytes
00
02
04
38
Write the
number
44
00
02
Uint16
DataLen)
Write
CRC
content
check
80
00
01
3B
24
CRC check
01
DD
23

Advertisement

Table of Contents
loading

Table of Contents