
AF5485 User Manual
- 8 -
TEL
:
020-89851175 / 89850036
www.aosong.com
v1.0-20170726
6
.
Repeat step 2 to step 5 to perform the next byte processing of the communication
information frame;
7
.
After all the bytes of the communication information frame are calculated as described
above, the high and low bytes of the resulting 16-bit CRC register are exchanged;
8
.
The final result of the CRC register is
:
CRC Code.
◎
C language calculation code of CRC Code
Note : This procedure calculates the CRC code(the start address of the bytes is ptr and the length is len)
unsigned short crc16(unsigned char *ptr, unsigned char len)
{
unsigned short crc=0xFFFF;
unsigned char i;
while(len--)
{
crc ^=*ptr++;
for(i=0;i<8;i++)
{
if(crc & 0x01)
{
crc>>=1;
crc^=0xA001;
}else
{
crc>>=1;
}
}
}
return crc;
}