LPC824 CRC CALC

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

LPC824 CRC CALC

Jump to solution
1,102 Views
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 ?

Labels (1)
0 Kudos
Reply
1 Solution
886 Views
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.

View solution in original post

0 Kudos
Reply
3 Replies
886 Views
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!
-----------------------------------------------------------------------------------------------------------------------

887 Views
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 Kudos
Reply
886 Views
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 Kudos
Reply