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.

TMS320F280049C: TMS320F280049C

Part Number: TMS320F280049C

I am trying to calculate a 32-bit CRC using the VCU0 module (integrated w/F28004x).  I am using the code section ".text" defined in the Linker to determine the start address of the CRC calculation and the end of the ".text" section to determine the length of the CRC calculation.  I then place the resulting CRC into a constant that does not reside in the ".text" section of the code to compare it to the calculated CRC.  However, when I change the value of this constant, the calculated CRC also changes.  I have done this in the past with other C2000 processors.  I don't understand what is happening.

Please help.

Steve Haddad

Ametek Aerospace

 

  • Steve,

    I sort of understand what you're trying to do, but am a bit confused at the same time. It appears you are trying to compute a CRC on a section of code labeled ".text" (seems too generic, isn't it already used, maybe good to switch it to something else like .crctext and modify .cmd accordingly?) and then compare it to a reference CRC. Presume you are obtaining this reference CRC through some other means/external algorithm? But when you change the reference CRC, the CRC computed by the VCU0 is also changing, indicating that the location of the reference CRC is also possibly used in the VCU0 CRC computation. Is my understanding correct?

    Have you looked at the generated .map file to confirm that the .text section of your code does not overlap with the reference CRC location?

    Also, I am on a business trip until Wednesday night, so my replies may be slightly delayed.

    Thanks,

    Sira

  • Sira:

    I have a solution but I am still confused. 

    Code Snipit

    SECTIONS  (Linker Command File)

    {

       codestart        : > BEGIN,                 PAGE = 0, ALIGN(4)

       .text            : > FLASH_BANK0_HALF1,

                 LOAD_START(_Prog_Start),

                 LOAD_SIZE(_Prog_Size),            PAGE = 0, ALIGN(4)

       .cinit           : > FLASH_BANK0_HALF1,     PAGE = 0, ALIGN(4)

       .pinit           : > FLASH_BANK0_HALF1,     PAGE = 0, ALIGN(4)

     

    I get the start location and the length of the program code from the linker.

    const unsigned long code_start = (unsigned long)&Prog_Start;

    const unsigned long code_size = (unsigned long)&Prog_Size;

    //Pre-calculated checksum parameters for BIT

    volatile const unsigned long ProgChksm = 0x72A5D9BD; //checksum value

    I believe that the “.text” section of flash contains only code, not constants or variables. I am using the following code to generate a CRC32 and compare it to the expected value (run 1st time to get the value, thereafter the compare should be valid). 

           Prog_VCU0_Chksm = getCRC32_vcu(INIT_CRC32, (uint16*)code_start,

                                                            (CRC_parity_e)CRC_parity_even, 2*code_size);

           if (ProgChksm != Prog_VCU0_Chksm) BIT_Status_Word.bits.Prog_Checksum = 1;

     

    I have shut off compiler optimization. This code now works but if I remove the “volatile” designation, the compiler optimizes out the constant ‘ProgChksm” and the generated checksum changes every time I change the value of ProgChksm.

     

    Thanks for your response.

     

    Steve Haddad

    Ametek Aerospace

  • Steve,

    Interesting behavior. I'm not the expert in this space, but can you try:

    1. Removing const from the declaration?

    2. Changing to a #define PROGCHKSUM instead of a variable declaration?

    Thanks,

    Sira