EasyManua.ls Logo

Sinee EM500 - Page 409

Sinee EM500
459 pages
Print Icon
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...
EM500 Open-Loop Vector Control Inverter User Manual
409
unsigned int CRC_Cal_Value(unsigned char *Data, unsigned char Length)
{
unsigned int crc_value = 0xFFFF;
int i = 0;
while(Length--)
{
crc_value ^= *Data++;
for(i=0;i<8;i++)
{
if(crc_value & 0x0001)
{
crc_value = (crc_value>>1)^ 0xa001;
}
else
{
crc_value = crc_value>>1;
}
}
}
return(crc_value);
}
The contents above illustrate CRC parity theory. It takes a long time for execution
with this method, especially when the parity data is long. Therefore, use the following
two loop-up table methods for 16-bit and 8-bit controllers
CRC16 look-up table for 8-bit processor: the finally returned result of this program
is with high byte in the front, so please reverse it while sending)
const Uint8 crc_l_tab[256] = {
0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,
0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,

Table of Contents