Hello,
I'm using MSP430F5418 microcontroller and try to use CRC16 hardware module. But
I don't understand, what software analog for this hardware parallel algorithm?
I'm try to use source codes from http://focus.ti.com/lit/an/slaa221/slaa221.pdf
, but hardware computation and software computation on the PC not coincide :(
Please, help me and give example source code (optative С code).
I'm also try to use this code:
/* The FCS calculation using simulated shift register with feedback */
unsigned short const g=0x1021; /* x16 + x12 + x5 + 1 generator polynomial */
unsigned short fcs_calc_in_shift_register(unsigned char *data, unsigned short count)
{
unsigned short fcs=0xFFFF; /* initial FCS value */
unsigned short d, i, k;
for (i=0; i<< 8;
for (k=0; k<8; k++)
{
if ((fcs ^ d) & 0x8000)
fcs = (fcs << 1) ^ g;
else
fcs = (fcs << 1);
d <<= 1;
}
}
return(fcs);
}
But it also not coincide with hardware module using procedure:
unsigned int SyGetCRC(unsigned char *buf, unsigned int sz, unsigned int init)
{
unsigned int i;
unsigned char ch;
CRCINIRES = init;
for (i = 0; i < sz; i++)
{
ch = *(buf + i);
CRCDI = ch;
}
return CRCINIRES;
}