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.

TMS570LS0432: my method is not successful,write value in flash

Part Number: TMS570LS0432

Hello

I want to write value in flash, my code

——————————————————————————————————————

#define CRCFLASH 0x43a42286d5a3d8dd

#ifdef __cplusplus
#pragma DATA_SECTION("parSet");
#else
#pragma DATA_SECTION(parSet,"parSet");
#endif

const uint64_t parSet = {CRCFLASH};

————————cmd————————————————————

memory

{

PARS(RW)            : origin=0x00040000 length=0x00000020

}

sections

{

   parSet             : {} > PARS

}

 why do the Address has no data?

Thank you

  • Hi Whong,

    1. The #pragma DATA_SECTION(..) is to create a data section for the the function or variable specified in this expression. The 

    The C/C++ compiler supports the ANSI/ISO standard keyword const in all modes. Global objects qualified as const are placed in the .const section

    So, please remove .const from your code:

    #define CRCFLASH 0x43a42286d5a3d8dd
    #pragma DATA_SECTION(parSet,"myCRCDataA");
    uint64_t parSet = {CRCFLASH};                  //removed .const

     

    2. Another reason is that the data or the section is not used in your code. By default, the linker eliminates sections that are not used in the executable module. There are two solutions:

    • 1. use the variable in your code:

    #define CRCFLASH 0x43a42286d5a3d8dd
    #pragma DATA_SECTION(parSet,"myCRCDataA");
    uint64_t parSet = {CRCFLASH};

    int main(void)
    {
        /* USER CODE BEGIN (3) */
          uint64 a, b, c;
         a = parSet;
          b= a & 0xFFFFFFFFFFFFFFF0;

    }

    • 2. disable the option of "unused_section_elimination" in linker configuration:

     

     

  • Hi

    QJ

    I have added the

    uint64 a, b, c;
         a = parSet;
          b= a & 0xFFFFFFFFFFFFFFF0;

    and  remove the const  ,but the flash also dont have data,

     please  you try 

  • I tried many times, but it still doesn't work

  • solve it