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.

RM57L843: CRC Calculation

Part Number: RM57L843

Tool/software:

Hi,

How do I calculate the CRC64 of data that is not a multiple of 64 bits? For example, I want to caluclate the CRC of following 10 bytes data

data = {0x00, 0x01, 0x02, 0x03, 0x04, 0x07, 0x08, 0x90, 0x12, 0x13}

What should I set src_data_pat and data_length fields to in crcModConfig_t structure?

Ravi

  • Ravi,

    Please expect a delayed response due to the Diwali holiday in India.

    Regards,

    Brennan

  • Hi Ravi,

    As per my understanding, the CRC compression will always happen for 64-bit data only.

    If you want to calculate CRC for 0x00, 0x01 and 0x02 then you should need to give 0x0000000000000000, 0x0000000000000001 and 0x0000000000000002.

    So, you can write your code something as below:

    #include "HL_crc.h"
    
    uint64_t Data_Buffer[10] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x07, 0x08, 0x90, 0x12, 0x13};
    
    uint8_t CRC_Completion_Flag = 0;
    crcConfig_t sCrcParams;
    uint64_t compressed_crc;
    
    int main(void)
    {
        crcInit();
        Data_Initialization();
    
        sCrcParams.crc_channel   = CRC_CH1;
        sCrcParams.mode          = CRC_FULL_CPU;
        sCrcParams.pcount        = 0u;
        sCrcParams.scount        = 0u;
        sCrcParams.wdg_preload   = 0u;
        sCrcParams.block_preload = 0u;
    
        crcChannelReset(crcREG1, CRC_CH1);
        crcSetConfig(crcREG1, &sCrcParams);
    
        deneme.mode             = CRC_FULL_CPU;
        deneme.crc_channel      = CRC_CH1;
        deneme.src_data_pat     = Data_Buffer;
        deneme.data_length      = 10;
    
        crcSignGen(crcREG1, &deneme);
        compressed_crc  =   crcGetPSASig(crcREG1, CRC_CH1);/*Reading the compressed CRC from the CRC module*/
        compressed_crc  =   swap_high32_with_low32(compressed_crc); /*Due to bug in crcGetPSASig the received CRC need to swap again*
    
        while(1);
    
        return 0;
    }

    You no need to mention higher bytes and it will consider higher bytes as all zeros as we declare the array size with 64-bit.

    --

    Thanks & regards,
    Jagadish.