CRC32 S32K144

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

CRC32 S32K144

460 Views
MadsNE
Contributor I

I have tried to implement the CRC32 found in a S32K144_Project_CRC example, but it is calculating wrong.

uint8_t test = 0x41;
uint32_t crc = 0x00000000;
crc = CRC_32bits_calculate(&test, 1);
Result: 0x209FAE1A
If I check the result online it should be 0xD3D99E8B.

The code in crc.c is unchanged:
define POLY (0x04C11DB7) 
uint32_t CRC_32bits_calculate(uint8_t *data, uint32_t size)
{

PCC->PCCn[PCC_CRC_INDEX] |= PCC_PCCn_CGC_MASK; /* enable CRC clock */
CRC->CTRL |= CRC_CTRL_TCRC(1); /* enable 32-bit CRC protocol */
CRC->CTRL |= CRC_CTRL_TOT(1); /* Bits in a byte are transposed, while bytes are not transposed. */
CRC->CTRL |= CRC_CTRL_TOTR(2); /* Both bits in bytes and bytes are transposed. */
CRC->CTRL |= CRC_CTRL_FXOR(1); /* XOR on reading. */
CRC->GPOLY = POLY;
CRC->CTRL |= CRC_CTRL_WAS_MASK; /* Set CRC_CTRL[WAS] to program the seed value. */
CRC->DATAu.DATA = 0xFFFFFFFF; /* seed value */
CRC->CTRL &= ~CRC_CTRL_WAS_MASK; /* Clear CRC_CTRL[WAS] to start writing data values. */
for(;size--;)
CRC->DATAu.DATA = *data++; /* write data values */
return (uint32_t) CRC->DATAu.DATA;
}

Can any explain the difference.

0 Kudos
Reply
0 Replies