LPC824 CRC CALC

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,100件の閲覧回数
pauloferreira
Contributor I

Using LPC824 CRC engine :

Polynomial = x16 + x12 + x5 + 1   (ccitt)
Seed Value = 0xFFFF
Bit order reverse for data input: Yes
1's complement for data input: NO
Bit order reverse for CRC sum: Yes
1's complement for CRC sum: NO
CRC_MODE = 0x0000 0014
CRC_SEED = 0x0000 FFFF

For string  "ABC" result crc   0x10f0

Using another devices to calc with same parameters result  0x60d0  (ex. CRC calculation )

Any ideas please ?

ラベル(1)
0 件の賞賛
返信
1 解決策
884件の閲覧回数
pauloferreira
Contributor I

Thanks Kerry.

My mistake was definition of CRC_WR_DATA pointer like  uint32_t .   

I was writing 32 bits at a time, and the correct was 8 bits to each sum.

Nice help. Regards.

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
884件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hello PAULO FERREIRA,

     I think your problem is caused by your LPC824 CRC configuration.

   Because I also test your desired CRC for "ABC" =0x41,0x42,0x43, I can get the correct CRC data 0x60d.

  Now, post my test code for your reference.

1.  Your desired information

Polynomial = x16 + x12 + x5 + 1   (ccitt)
Seed Value = 0xFFFF
Bit order reverse for data input: Yes
1's complement for data input: NO
Bit order reverse for CRC sum: Yes
1's complement for CRC sum: NO

According to the register description

pastedImage_1.png

So, MODE should be:0x14 .

2. function

static const uint8_t kerrytest[] = {0x41,0x42,0x43};

uint32_t kerry_result;

In main, call:

int main(void)
{


    /* Board Initialization */
    SystemCoreClockUpdate();
    Board_Init();

    /* Chip Initialization */
    Chip_CRC_Init();

    /* Enable SysTick Timer */
    SysTick_Config(SystemCoreClock / TICKRATE_HZ);

    /* Loop tests with occasional forced error */
    while (1) {
      kerry_test(kerrytest,3);

    }
}

void kerry_test(const uint8_t *data, uint32_t bytes)
{
    
    LPC_CRC->MODE = 0x14;
    LPC_CRC->SEED = CRC_SEED_CCITT;

    while (bytes > 0) {
        Chip_CRC_Write8(*data);
        data++;
        bytes--;
    }
      kerry_result = Chip_CRC_Sum();//Chip_CRC_CRC8(kerrytest, 3);
}

After test, the debug result is:

pastedImage_8.png

You can find the kerry_result is 0x60d0 .

3. Use CRC calculation tool

CRC calculation 

pastedImage_9.png

In conclusion, you can find the result in  CRC calculation tool and the LPC824 code is the same.

Wish it helps you!

If you still have question, please kindly let me know!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

885件の閲覧回数
pauloferreira
Contributor I

Thanks Kerry.

My mistake was definition of CRC_WR_DATA pointer like  uint32_t .   

I was writing 32 bits at a time, and the correct was 8 bits to each sum.

Nice help. Regards.

0 件の賞賛
返信
884件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hello PAULO FERREIRA,

  That's very good to hear your problem is solved.

   If your problem is solved, please help me to mark the correct answer to close this question.

   Thank you and have a nice day!

Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信