Specify static variable location

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

Specify static variable location

958 Views
Mike_d
Contributor IV

Hi,

Can someone please tell me how to specify the flash location of a const variable for a Kinetis MCU using CW 10.2?  I wan't to load a specific 32-bit value at a specific flash location.

Thanks,

-Mike

0 Kudos
4 Replies

581 Views
Monica
Senior Contributor III

Mike, how is it going?

Were your doubts clarified?

Regards! :smileyhappy:

0 Kudos

581 Views
carlos_neri
NXP Employee
NXP Employee

a very similar example like the one Luis provided can be found on this post:

Linking an array to a fixed address

The "@" method is not supported on the ARM compiler on CW.

0 Kudos

581 Views
LuisCasado
NXP Employee
NXP Employee

Hello,

Declare your variable in the source code:

 

#pragma define_section constdata ".constdata" R 

#pragma section constdata begin 

int My_variable = 0x55AA; 

#pragma section constdata begin

Then you have to edit your linker file, something like:

.constdata :

{

    *(.constdata)

     .= ALIGN(0x4) ;

} > my_data

And define my_data section on memory, it depends on the device and memory location you want:

MEMORY {

m_interrupts  (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001E0

my_data      (RX) : ORIGIN = 0x00000800, LENGTH = 0x00000100

m_text        (RX) : ORIGIN = 0x00000900, LENGTH = 0x00040000-0x00000800

m_data        (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x00010000

m_cfmprotrom  (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010

}

I hope this helps.

Luis

0 Kudos

581 Views
Mike_d
Contributor IV

So nothing as simple as:


volatile uint32 my_const @0x4A0 = 0x00C00FAB;

that I used with a ColdFire?

0 Kudos