23
6.4.3 Write multiple registers command 0x10
Host -> Slave Data
Device
address
Function
code
The
starting
address
Write
the
number
The
number
of
bytes
Write
content
Write
content
CRC
check
01
10
00
44 00 02 04
38 80 00 01 3B 24
Slave -> Host Data
Function
code
The starting
address
Write the
number
CRC check
01
10
00
44
00
02
01
DD
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.
Uint16
Funct_CRC16
(
unsigned char
* puchMsg,
Uint16
DataLen)
{
Uint16
i,j,tmp;
Uint16
crcdata=0xFFFF;
for
(i=0;i<DataLen;i++)
{
crcdata=(*puchMsg)^crcdata;
+;
for
(j=0;j<8;j++)
{
tmp=crcdata&0x0001;
crcdata=crcdata>>1;
if
(tmp){
crcdata=crcdata^0xA0
01;
}
} }
return
crcdata;
}