What should be the value of seed and generator polynomial?

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

What should be the value of seed and generator polynomial?

1,385 Views
beingalpha18
Contributor I

Hi,

I am using CRC module of S32K142, But I am not able to understand what should be the value of seed and generator polynomial for real CRC calculation on data. 

Labels (1)
Tags (1)
0 Kudos
2 Replies

1,343 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Mr Alpha,

You can read: Understanding and implementing CRC (Cyclic Redundancy Check) calculation

seed also calls initial value

Hope it helps!

Best Regards,

Robin

 

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

0 Kudos

1,343 Views
kef2
Senior Contributor IV

Hi,

Seed and poly depends on CRC type. This routine works for 16 bits CRC-CCITT (0x1021 poly):

unsigned int crc16(const void* buf, size_t len)

{

char oddlen;

union{

   unsigned char *c;

   unsigned short *s;

   unsigned long *l;

}ptr;

               PCC->PCCn[PCC_CRC_INDEX] |=PCC_PCCn_CGC_MASK;

 

    CRC->CTRL |= CRC_CTRL_TCRC_MASK;

    CRC->GPOLY = 0x10210000;          // poly <<16

    CRC->CTRL |= CRC_CTRL_WAS_MASK;

    CRC->DATAu.DATA = 0x0;

    CRC->CTRL &= ~CRC_CTRL_WAS_MASK;

 

    ptr.l = (void*)buf;

    oddlen = len & 3;

    len /= 4u;

    while(len--)

    {

               CRC->DATAu.DATA = __builtin_bswap32(*ptr.l++);;

    }

    while(oddlen--)

    {

               CRC->DATAu.DATA_8.LL = *ptr.c++;

    }

    return CRC->DATAu.DATA_16.H;

}

Edward

0 Kudos