Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 2. Thank you for your patience.

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.

AM2634: How to implement CRC-32 check Without using SDK examples

Part Number: AM2634

Tool/software:

Hi Teams,

1. My requirement is not to use the example code (MCRC)which you provided in the sdk.

    so here i created the crc function of my own(sample implementation in below i attached) in that i need to find the crc by using my function.

    below i attached my sample code to calculate crc,

typedef struct {
    uint32_t Polynomial;
    uint32_t Initial;
    uint32_t FinalXor;
    uint32_t RefelectDataFlag;
    uint32_t RefelectRemainderFlag;
    CRC_Type Type;  //< New field to specify the CRC type
} ST_CRC32_PARAM;

uint32_t CRC32Calculate(const uint8_t* data, uint32_t length, const st_CRC32_param* ptrParam)
{
    uint32_t result;
    uint8_t buffer;
    if ((length != EMPTY_BUFFER) && (ptrParam->polynomial != EMPTY_BUFFER)) // Checking if data is valid
    {
        uint32_t crc = ptrParam->initial;
        for (uint32_t i = 0U; i < length; i++)
        {


            // Use reflection based on RefelectDataFlag
            if ((ptrParam->RefelectDataFlag) != 0U)
            {
                buffer = (uint8_t)ReverseBits(data[i], BYTES_BY_BYTES); // Reflect data
            }
            else
            {
                buffer = data[i]; // No reflection
            }

            // XOR buffer with the relevant bits of the current CRC
            buffer ^= (uint8_t)(crc >> (WIDTH - BYTES_BY_BYTES)); // Explicit cast to 8-bit

            // Update CRC using the lookup table and polynomial
            crc = CRCTableCreation[buffer] ^ (crc << BYTES_BY_BYTES);
        }

        // Use reflection for the final CRC value based on RefelectRemainderFlag
        if ((ptrParam->RefelectRemainderFlag != 0U)) // Explicit boolean condition
        {
            result = (ReverseBits(crc, WIDTH) ^ ptrParam->finalXor); // Reflect final CRC
        }
        else
        {
            result = (crc ^ ptrParam->finalXor); // No reflection
        }
    }
    else
    {
        result = 0U; // RESULT 0 for invalid input
    }
    return result;
}

so, here i need to calculate the CRC for the whole RAM memory(Because our code which is store in OCRAM) so, I need to implement with out using  SDK provided examples.


2. i want your approach let suppose we know the RAM address starting from  OCRAM : ORIGIN = 0x70040000 , LENGTH = 0x100000

how can we read the RAM memory? and how to do CRC? 

  • how can we read the RAM memory? and how to do CRC? 

    Do you want to calculate the CRC using SW method instead of using the hardware MCRC module?

    To calculate the CRC using MCRC hardware without using SDL, you need to program the MCRC registers correctly:

    1. MCRC controller reset:  CRC_CTRL0 register

    The MCRC controller should be reset before configuring the MCRC controller. Writing 1 to the channel (x) PSA software reset bit in the Control Register (CRC_CTRL0) resets the corresponding PSA signature register for that CRC channel (x).

    mcrc->CTRL0 |=0x00000001U; to reset channel 1.

    2. Configure Pattern Count Registers (PCOUNT_REG)

    The data pattern counter is a 20 bit down counter and can be pre-loaded with a programmable value stored in the pattern count register. When the data pattern counter reaches zero automatic signature verification is performed in AUTO mode.

    mcrc->PCOUNT_REG1 = 0x...  to setup pattern count preload register for channel 1 

    mcrc->SCOUNT_REG1 = 0x...  to setup sector count preload register for channel 1

    3. Configure MCRC Controller Mode of Operation

    The MCRC controller can operate in one of the following modes: AUTO mode, Full-CPU mode, and Semi-CPU mode

    mcrc->CTRL2 |= mode;  to setup the Channel mode

    4. Write data to PSA Signature Register

    PSA Signature Register: This register can be both read and written. Each time PSA signature register is written, a signature is generated. The MCRC controller supports doubleword, word, half word and byte access to the PSA signature register. During a non-doubleword write access, all unwritten byte lanes are padded with zero’s before compression.

    for (...){

          mcrc->PSA_SIGREGL1 = *ptr64;

     }

    5. CRC Value Register

    This register stores the pre-determined CRC value. After one sector of data patterns is compressed by the PSA signature register, the MCRC controller can automatically compare the resulting signature stored at the PSA signature register with the pre-determined value stored at the CRC value register.