MPC5606B Configure variable in RAM to run

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MPC5606B Configure variable in RAM to run

3,187件の閲覧回数
明伟张
Contributor III

firstly,the global variable are configured to flash address which i defined; i hope the variable copy to RAM address which i defined when workspace start running;

can offer me sample code?

 

thanks!

ラベル(1)
0 件の賞賛
返信
6 返答(返信)

2,847件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

here is the example:

In linker file I added myROM and myRAM segment:

MEMORY

{

    resetvector:           org = 0x00000000,   len = 0x00000008

    init:                   org = 0x00000020,   len = 0x00000FE0   

    exception_handlers:    org = 0x00001000,   len = 0x00001000

    internal_flash:        org = 0x00002000,   len = 0x000FD000

   

    myROM:                     org = 0x000FF000,   len = 0x00001000

   

    internal_ram:          org = 0x40000000,   len = 0x00011000

   

    myRAM:                       org = 0x40011000,   len = 0x00001000

   

    heap  :                org = 0x40012000,   len = 0x00001000

    stack :                org = 0x40013000,   len = 0x00001000

}

Then use this syntax in SECTION:

SECTIONS

{

...

.myRAM BIND(ADDR(myRAM)) LOAD (ADDR(myROM)): {} > myRAM

...

}

And then in *.c file:

#pragma push

#pragma section sdata_type ".myRAM" ".myRAM"

unsigned int my_var1 = 0x11223344;

unsigned int my_var2 = 0xAABBCCDD;

unsigned int my_var3 = 0x55556666;

#pragma pop

The initial values will be copied during startup from myROM to variables in myRAM.

Regards,

Lukas

0 件の賞賛
返信

2,847件の閲覧回数
明伟张
Contributor III

the two question is not  same! In fact,for exampel:

i define a variable in flash as follow:

MEMORY

{

...

my_flash:   org = 0x003FF000,   len = 0x00001000

...

}

SECTIONS

{

...

.__my_flash LOAD (0x003FF000): {} > my_flash

...

}

In *.c file:

#pragma push

#pragma section all_types ".__my_flash" ".__my_flash "

uint32_t test = 0x1234;

#pragma pop

if it is OK,i want the variable "test" initial values can be copied during startup from my_flash to variables in myRAM.

so how to configure the myRAM in  *.c file:?? thanks! can offer me a sample code?

thanks verry verry much!!!!

0 件の賞賛
返信

2,847件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

you have to do it exactly in the same way as I showed in my previous post if you want to have variable in RAM that is initialized during startup.

The above can be used only for constant in flash.

Regards,

Lukas

0 件の賞賛
返信

2,847件の閲覧回数
明伟张
Contributor III

Hi,

I know,thanks.

but i also have a question,the variable is configured in Flash,i want the variable copy to ram address which i defined before MCU run?

0 件の賞賛
返信

2,847件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

that's what it does. In the example above, the startup files will copy the initial values stored in myROM to myRAM.

Lukas

0 件の賞賛
返信

2,847件の閲覧回数
明伟张
Contributor III

thanks! the problem is OK!

0 件の賞賛
返信