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.

F28335 Place a Constant in a Specific Location in Flash

Greetings,

 

I am trying to place a value in a specific location in flash by using the following construct.

#pragma DATA_SECTION(".MyValue")

static const uint32_t ExpectedValue = C_EXPECTED_VALUE;

 

 

C_EXPECTED_VALUE is defined in Predefined Symbols as follows:

C_EXPECTED_VALUE=0x12345678

 

 

In F28335.cmd I have placed the following:

MEMORY

   VALMEM      : origin = 0x338000, length = 0x000002

   FLASHA      : origin = 0x338002, length = 0x007F7E

 

SECTIONS

   .MyValue           : > VALMEM      PAGE = 0

 

The linker is staying out of the space defined in the memory section, but I don’t see the value 0x12345678 being placed in the memory. What am I missing?

 

Thank you,

 

Ed

  • Hello again,

     

                    I figured out the issue.  I was only using that variable in one location, so the optimizer was simply substituting the value which is exactly what I was trying to prevent.  I discovered that if I took the address of the variable and then the value at that address, the compiler would not optimize it away and the linker would place the value in the flash.

     

    Ed