LPC800的CRC在各种配置下是如何计算的?求详解。

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC800的CRC在各种配置下是如何计算的?求详解。

438 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hhxianzi on Sat Aug 31 04:57:03 CDT 2013
如题,在周立功网站上下载的LPC800例程里的CRC部分,代码如下:

/*********************************************************************************************************
** Function name:       CRCInit
** Descriptions:        CRC模块初始化
** input parameters:    无
** output parameters:   无
** Returned value:      无
*********************************************************************************************************/
void CRCInit (void)
{
    LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 13);                             /* 打开CRC模块时钟              */
   
    LPC_CRC->MODE = ((1 << 0) |                                         /* 多项式选择为 CRC_16          */
                     (1 << 2) |                                         /* IN_DATA 位序反转:YES        */
                     (0 << 3) |                                         /* IN_DATA 对1取补:NO          */
                     (1 << 4) |                                         /* CRC_SUM 位序反转:YES        */
                     (0 << 5));                                         /* CRC_SUM 对1取补:NO          */
   
    LPC_CRC->SEED =  0x00000000;                                        /* 种子值:0x0000 0000          */
}

/*********************************************************************************************************
** Function name:       main
** Descriptions:        CRC_16 例程:
**                      LED连接P0.7。
**                      运行程序,进行CRC_16测试,若测试通过,点亮LED,若测试失败,LED闪烁。
** input parameters:    无
** output parameters:   无
** Returned value:      无
*********************************************************************************************************/
int main (void)
{
    SystemInit();                                                       /* 初始化目标板,切勿删除       */
    GPIOInit();                                                         /* GPIO初始化                   */
    CRCInit();
   
    LPC_CRC->WR_DATA_WORD = 0x3534;
    if (LPC_CRC->SUM != 0xD7D6) {                                       /* 测试失败,LED闪烁            */

……

……

其中:LPC_CRC->SUM 应该是什么值?怎么计算的?

现在我的LED一直闪烁。

Labels (1)
0 Kudos
Reply
1 Reply

378 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Irving on Mon Nov 25 20:35:32 CST 2013
[img=613x106]/zh-hans/system/files/u1296/CRC.JPG[/img]
请参照对应的CRC计算方式, 用户手册User Manual有简单的介绍! 关于CRC的详细介绍可找度娘或谷哥, 谢谢
0 Kudos
Reply