2014-03-04 35 views
2

我已经通过CCITT和TI关于msp430的文档。是否可以使用任何内置函数为MSP430F5438A计算CRC?或者我必须为每次采集的数据计算CRC。使用内置函数计算crc为msp430f5438a的方法

+0

你见过这个线程:它可以实现如下? http://e2e.ti.com/support/microcontrollers/msp430/f/166/t/19030.aspx – bblincoe

回答

0

可以使用软件实现代替在MSP430F5438A上使用硬件外设。

unsigned short crc16(volatile unsigned char *sbuf,unsigned char len){ 
    unsigned short crc=0xFFFF; 

    while(len){ 
     crc=(unsigned char)(crc >> 8) | (crc << 8); 
     crc^=(unsigned char) *sbuf; 
     crc^=(unsigned char)(crc & 0xff) >> 4; 
     crc^=(crc << 8) << 4; 
     crc^=((crc & 0xff) << 4) << 1; 
     len--; 
     sbuf++; 
    } 
    return crc; 
}//crc16() 

斯 - 迈克尔·格罗斯的代码礼貌@ e2e.ti.com(http://e2e.ti.com/support/microcontrollers/msp430/f/166/t/19030.aspx