请问这段单片机代码中 uchar code ds_rom1[]={0x28,0x22,0x22,0x22,0x00,0x00,0x00,0xca};
前54位编码生成的CRC码我不管用网上的多字节算法还是查表法都算不到0xca 有大神知道怎么算到的0xca吗?
比如我用的如下程序,生成的CRC码是0x7d:
unsigned char test[7] = {0x28,0x22,0x22,0x22,0x00,0x00,0x00};
unsigned char len = 7;
void main( void )
{
unsigned char crc=0x00;
unsigned char i;
unsigned char *ptr = test;
while( len-- ) {
crc ^= *ptr++;
for(i=8; i>0; --i) {
if (crc & 0x80)
crc = (crc << 1) ^ 0x31;
else
crc = (crc << 1);
}
}
printf("0x%x ",crc);
}
|