This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RM48 CRC16 Help

Hi,

I am wishing to use the RM48's CRC module to generate a CRC16 (polynomial 0x1021).

I have software based libraries working well for years, however can not get the hardware CRC module to produce the same results.

Here is my input array and the function call:

Luint8 u8Buffer[] = {0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x01, 0x02};
u16HWCRC = u166RM4_CRC__Calculate_CRC16((const Luint16*)&u8Buffer[0], 8, 0x1021);

Here is my hardware CRC code:

Luint16 u166RM4_CRC__Calculate_CRC16(const Luint16 * pu16Data, Luint32 u32CRCLengthBytes, Luint16 u16CRC_Seed)
{
    Luint32 u32Counter;
    Luint32 u32LengthWords;
    union
    {
    	Luint16 u16[2];
    	Luint32 u32;
    }unT;

    //reset the module
	crcREG->CTRL0 = 0x00000001U;
	crcREG->CTRL0 = 0x00000000U;

	//clear control reg2 and set into full CPU mode
	crcREG->CTRL2 = 0x00000000U;
	crcREG->CTRL2 |= CRC_FULL_CPU;

	//place the seed in the PSA register Low
	unT.u16[1] = 0;
	unT.u16[0] = u16CRC_Seed;
	crcREG->PSA_SIGREGL1 = unT.u32;


	//write the groups of U16's to the register
	u32LengthWords = u32CRCLengthBytes >> 1;

    for(u32Counter = 0; u32Counter < u32LengthWords; u32Counter++)
    {
    	//update only the lower word of the REGL
    	unT.u16[1] = 0;
    	unT.u16[0] = pu16Data[u32Counter];
    	crcREG->PSA_SIGREGL1 = unT.u32;
    }

    //return with the CRC
    unT.u32 = crcREG->PSA_SIGREGL1;
    return (Luint16)unT.u16[0];
}

The result from the CRC across the data array should be 0x6DD2, however I get 0xFEF8.  Can anyone please help to show what I am doing wrong?

Note:  I am using Full CPU mode for the time being.

Thanks

Stomp.

  • Hello Stomp,

    I'm looking in to your issue, will get back to you soon.

  • Hello Stomp,

    Sorry for a little delay with this response.

    our CRC is based on a 64-bit PSA derived from a primitive polynomial as per the following equation 

    f(x) = x64+ x4+ x3+ x + 1.

    During a non-doubleword write access to PSA, all unwritten byte lanes are padded with zero’s before
    compression, and the compressed value is always expressed in 64 bit.

    I will still check with our CRC experts.

    Best Regards,

    Karthik.

    PS: If this answers your question, please click verify answer to close this thread.

  • Hi Karthik,

    I've had a good look through the PSA module, and yeah looks like it can only do one type of equation.

    Which means the module is really useless for most of the normal things we would want to use a CRC module for: 

    Example 7bit and 16bit CRC for SD memory cards, 16bit for external FLASH memories, 8bit for black channel communication across CAN channels.

    Maybe on the next silicon revision they could make the PSA equation programmable via a bit mask?,

    Kind Regards

    Stomp.

  • Hello Stomp,

    CRC module available in Hercules platform is mainly targeted for verifying the integrity of our memory sub-system.

    But I will certainly pass your feedback to respective folks here in TI.