How can I map flash to ram?

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

How can I map flash to ram?

731 Views
兜里揣caca
Contributor II

Hi,

The chip I use is MC9S12XET256,How should I copy flash to RAM, and then I change the operation of the flash address to the operation of the RAM address, for example, I assign the 0x4000, and the address 0x2000 will change accordingly  Thanks!

0 Kudos
3 Replies

532 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

there are two possible ways.

1) I will create a special RAM space and create a function as a RAM function in the Code Warriror. Then the process automatically creates a special function which is stored in the flash and after reset the copydown function (automatically added by codewarrior) copies the function from the flash to ram. The linker knows the function as a ram function and application executes the function always from ram.

2) The second approach is to exclude some ram space form the usage by codewarrior and use it for own purposes or use the stack as the space for temporary "ram function" which is copied

    a) always before usage from flash to ram and then it is executed. The difference is that if i copy it to given (the same) space then I can call the function always from the same address. however, iif I copy it to stack then addres is always different.

    b) only once after reset to the given ram space and then it is executed from known address by pointer to a function.

In these cases, the process is not automatic as in the item 1), so the function must by stored into a flash as a PIC (position independent code).

As an example I can direct you to my answer in the thread how to copy rom to ram(mc9s12xep100) 

however, if it does not help, could you please refine the question on the basis of my description to do not prepare redundant answer/example.

Best regards,

Ladislav

0 Kudos

532 Views
兜里揣caca
Contributor II

Thanks for your answer!

now,My initial value of the calibration parameters in the ECU Flash location is from 0x4000 to 0x155 bytes of Flash space, the ADD_RMAPPING function is set up, the space to start from 0x2000 is also 0x155 bytes of RAM space. Through this setting, INCA will automatically send to 0x4155 Flash space switching to 0x2155 pairs of 0x2000 RAM space operation on 0x4000 here, would you please tell me how to set the ADD_RMAPPING function?

0 Kudos

532 Views
lama
NXP TechSupport
NXP TechSupport

I am really sorry but we are really confused of your task description. Please refine it to better understand. Now, how we see it:

1) There are some data in the flash space 0x4000~0x4154

2) You will copy these data to the space 0x2000~0x2154

3) There is some function in the flash which uses data stored in the flash 0x4000~0x4154 and you want to be this function able to read the data from the 0x2000~0x2154.

Is my understanding correct? If yes, is there any flag or event which says you want to use different memory. If yes then the easiest approach are pointers.

For example:

unsigned char *data;

if(readfrom_flash_flag) data=0x4000;

else                               data=0x2000;

for(i=0; i<0x155;i++)

{

  x=data[i];       // either

  x=*(data+i);   // or

}

INCA - ??? what is it related to??? Is it used in some loop function;

I understand you absolutely understand what you want to do but try to explain it to the person who knows nothing about your issue.

Best regards,

Ladislav

0 Kudos