How to moved variable to certain section of RAM memory

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

How to moved variable to certain section of RAM memory

878 Views
vikasb
Contributor II

I want to know is  there in method to align the indivialial variable declared is such way that blow variable can be  moved

to some section of RAM memory,

 

I want align below variable to RAM memory section to 0x40005000

 

volatile real32_T Main_KD = 6.0F; RAM address = 0x40005000
volatile real32_T Main_KD_limit = 1.0F; RAM address = 0x40005004
volatile real32_T Main_KP1 = 4.0F; RAM address = 0x40005008
volatile real32_T Main_KP2 = 2.0F; RAM address = 0x4000500C
volatile real32_T Main_KP_conv1 = 0.15F;  so on
volatile real32_T Main_KP_conv2 = 1.0F;
volatile real32_T Main_Threshold_off = 1.0F;
volatile real32_T Main_Threshold_on = 2.0F;
volatile real32_T Main_deadbandA = 0.0F;
volatile real32_T Main_deadbandB = 0.0F;

Labels (1)
0 Kudos
4 Replies

758 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

which device and which IDE do you use?

Regards,

Lukas

0 Kudos

758 Views
vikasb
Contributor II

Hello Luncas,

I’m using the MPC5553 controller with codewarrior IDE v2.8 for developing the software.

-Vikas

0 Kudos

758 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Here is simple example which I copied from some old test project.

In linker file:

MEMORY

{

...

my_ram:          org = 0x40030000,   len = 0x0000C000   //just example, use addresses you need

...

}

SECTIONS

{

...

.__my_ram: {} > my_ram

...

}

In *.c file:

#pragma push
#pragma section all_types ".__my_ram" ".__my_ram" data_mode=far_abs
volatile unsigned int data1;

volatile unsigned int data2;

volatile unsigned int data3;
#pragma pop

The order of data1, data2, data3 in RAM will be the same as order in this section. You can check it in the map file.

Regards,

Lukas

0 Kudos

758 Views
vikasb
Contributor II

Thanks for help, now I could manage the RAM memory addressing as per my need.

0 Kudos