ram to flash function

cancel
Showing results for 
Search instead for 
Did you mean: 

ram to flash function

Jump to solution
396 Views
Contributor II

Hi,

I wanto to store the value of a variable before disconnect my Qorivva Microcontrller.

If it was possible:

 

int my_var1 = 7; // RAM variable

const int my_var2; // FLASH variable

void ram2flash(void)

{

     my_var2 = my_var1;

}   

and once I run ram2flash  than I have 7 stored in my_var2 even if I restart.

Labels (1)
0 Kudos
1 Solution
23 Views
NXP Employee
NXP Employee

Carlos,

You cannot assign a variable value to a constant. It does not work this way.

in order to modify Flash memory you need to use special routines to erase/program flash memory.

Also Flash memory can be erased/programmed in blocks in contrast to EEPROM.

Please refer to the reference manual of your MCU, section "C90LC Flash memory" for more details about Flash memory programming.

You can possibly re-use some existing C90LC Flash memory drivers available on Freescale web.

e.g.:

Freescale Search

BR

Stanislav

View solution in original post

0 Kudos
3 Replies
23 Views
Contributor II
0 Kudos
24 Views
NXP Employee
NXP Employee

Carlos,

You cannot assign a variable value to a constant. It does not work this way.

in order to modify Flash memory you need to use special routines to erase/program flash memory.

Also Flash memory can be erased/programmed in blocks in contrast to EEPROM.

Please refer to the reference manual of your MCU, section "C90LC Flash memory" for more details about Flash memory programming.

You can possibly re-use some existing C90LC Flash memory drivers available on Freescale web.

e.g.:

Freescale Search

BR

Stanislav

View solution in original post

0 Kudos
23 Views
NXP Employee
NXP Employee

If you use the default New Project wizard settings, the Internal ROM target links all constants into the .rodata, the .rdata and the .sdata2 sections for you. The following code snippets show how this is done.

Snippet of .lcf file :

----------------------


MEMORY

{

    boot_flash:           org = 0x00000000,   len = 0x00010000

    interrupts_flash:     org = 0x00010000,   len = 0x00010000

    internal_flash:       org = 0x00020000,   len = 0x00060000

    internal_ram:         org = 0x40000000,   len = 0x00007C00

    stack_ram:            org = 0x40007C00,   len = 0x0400

}

...

 
   GROUP : {
     .intc_sw_isr_vector_table ALIGN (2048) : {} /* For INTC in SW Vector Mode */

       .text_vle (VLECODE) ALIGN(0x1000): {
             *(.text)
             *(.text_vle)
             *(.fini)
             *(.eini)
         }
       .init  : {}
       .init_vle (VLECODE) : {
             *(.init)
             *(.init_vle)
          }
        .ctors : {}
        .dtors : {}
        .rodata (CONST) : {
            *(.rdata)
            *(.rodata)
         }
     .sdata2       : {}
     extab      : {}
     extabindex : {}
  }  > internal_flash

0 Kudos