ram to flash function

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

ram to flash function

跳至解决方案
1,539 次查看
Stevanatto
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.

标签 (1)
0 项奖励
回复
1 解答
1,166 次查看
stanish
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

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,166 次查看
Stevanatto
Contributor II
0 项奖励
回复
1,167 次查看
stanish
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

0 项奖励
回复
1,166 次查看
TICS_Fiona
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 项奖励
回复