|
請問這段單片機代碼中 uchar code ds_rom1[]={0x28,0x22,0x22,0x22,0x00,0x00,0x00,0xca};
前54位編碼生成的CRC碼我不管用網(wǎng)上的多字節(jié)算法還是查表法都算不到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);
}
|
|