Jump to content
43oh

Initializing flash segment from CCS compiler/linker ?


Recommended Posts

I have figured out how to use flash memory to persist values in the MCU, like to survive across a power failure. So that is cool.

 

One last thing is how does one get the CCS C++ compiler/linker to initialize a flash segment? Does anyone have a technique for initializing a segment?

 

For example, I am mapping the persistent values into SEGMENT_C. The C++ compiler/linker does not, at least as mine is setup, initialize the flash segment. It always has the same values from the last time the program wrote values in there, even when the program is rebuilt and reloaded into the MCU.

 

I have been experimenting with #pragma location= and #pragma LOCATION(x,address) in an attempt to initialize a static variable into SEGMENT_C. But the C++ compiler is saying those are unknown pragmas.

 

Does anyone know the technique to get the CCS C++ compiler/linker to initialize a flash memory segment like SEGMENT_C to something like all 0x00 or all 0xFF?

 

Thank you,

 

 

Link to post
Share on other sites

I had come across this article as well and it looks to have the answers. In my attempts to use the CCS #pragma statements the compiler warns it does not recognize them. Hopefully it is a setting somewhere that will let them work. Still researching.

 

Thank you for the effort!

Link to post
Share on other sites
  • 2 weeks later...

The "secret" to having the compiler/linker erase/set the flash memory when a program is flashed in has been solved.

 

In CSS right-click on the project and select Properties.  Select Debug then MSP43x Options. In there select under Erase Options "Erase main and information memory."

 

Now whenever a new program is flashed to the MCU the SEGMENTB, C, and D are initialized to 0xFF in every byte. Perfect!

 

Hope this helps someone else out there!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...