Diective to force data into flash

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Diective to force data into flash

532 Views
rmaier
Contributor III

Hello,

Can someone please explain to me how to force the compiler to store a variable into NVM? I am using CodeWarrior 10.5 with a Kinetis EA MCU. My problem is I declare an array into NVM in a fixed flash area by way of this:

__attribute__ ((section(".startupDat")))

volatile const UINT16 LEDStat[4] = {45, 18, 0, 0xCCCC};

The data is discarded unless I add something like the following in my code:

x = LEDStat[0];

How can I force the compiler to do what I want? Many thanks for your support.

2 Replies

415 Views
BlackNight
NXP Employee
NXP Employee

Hi Robert,

you need to tell this to the linker with a KEEP, see Defining Variables at Absolute Addresses with gcc | MCU on Eclipse .

I hope this helps,

Erich

415 Views
rmaier
Contributor III

Thank you Erich. Just what I was looking for.

0 Kudos