標(biāo)題: CRC循環(huán)校驗 [打印本頁]

作者: richthoffen    時間: 2015-2-1 19:58
標(biāo)題: CRC循環(huán)校驗
uint crc16l(uchar *ptr,uchar len) // ptr 為數(shù)據(jù)指針,len 為數(shù)據(jù)長度
{
uchar i;
while (len--)
{
for(i=0x80; i!=0; i>>=1)
{
if((crc&0x8000)!=0) {crc<<=1; crc^=0x1021;} 1-1
else crc<<=1; 1-2
if((*ptr&i)!=0) crc^=0x1021; 1-3
}
ptr++;
}
return(crc);
}

我對1-1 1-2 1-3 行不是很懂,能講解一下嗎,想了很久還是沒結(jié)果,麻煩你了

單片機通信系統(tǒng)中CRC算法與硬件環(huán)境編程的實現(xiàn)(pdf),根據(jù)第七個方程編出以上代碼,我很不理解



作者: admin    時間: 2016-4-7 03:54
循環(huán)冗余校驗(CRC)算法入門引導(dǎo):http://www.torrancerestoration.com/bbs/dpj-47737-1.html
最通俗的CRC校驗原理剖析:http://www.torrancerestoration.com/bbs/dpj-47736-1.html
CRC8校驗分析:http://www.torrancerestoration.com/bbs/dpj-47738-1.html
作者: liuyimao485812    時間: 2016-4-7 09:12
1-1 CRC 先左移1位,然后與0x1021進行異或運算
1-2 CRC 左移1位
1-3 與0x1021進行異或運算




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1