CodeWarrior 10.6, mpc5604 defines variables in the specified flash area

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

CodeWarrior 10.6, mpc5604 defines variables in the specified flash area

681 Views
ahjg_xu
Contributor II

Hello! I use mpc5604p and now use CodeWarrior 10.6 compiler. I want to directly define variables in the specified flash area (the flash area is the start page) when compiling the program.

When I use ac512, @ can realize this function. However, mpc5604 failed and the compiler reported an error; Hope to get your help to realize this function, thank you

0 Kudos
Reply
1 Reply

674 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

If you just want have to have variable in flash, it cannot be done just because variable suppose its location in volatile memory, whilst flash is non-volatile memory.

 

Here I have described how it is possible to relocate code to the RAM:

https://community.nxp.com/t5/MPC5xxx/MPC560xB-Copy-a-code-from-flash-to-RAM-for-executing-it-in-RAM/...

 

Similar approach can be used with data as well but

 

- variable is already located in RAM whilst its default value is being loaded from flash during init, thus I don’t see any reason for relocation

int i = 10;

 

- if you need specific alignment, use pragma aligned like this (aligns to 8 bytes)

vuint32_t test[2] __attribute__ ((aligned (8))) =

{

    0xBABADEDA,

    0xABBAABBA

};

 

- if you really need to access specific address, you can do it as follows where 0x40000000 specifies address (don’t forget to reserve space in linker command file) for this accesses:

*(unsigned int*)0x40000000  = 0x44444444;

0 Kudos
Reply