AnsweredAssumed Answered

(MPC5553)How can I configure global variable in flash memory

Question asked by Lim Heesun on Jan 3, 2016
Latest reply on Jan 4, 2016 by Lim Heesun

I want to configure global variable in specific flash address(High address 0x00160000:H7 Block).

so I used flash erase and write sequence function with the Manual.

And EPPC Target in Target settings panels, Small Data and Small Data2 -->0

 

So, I can check the variable is configured in address 0x00160000

Now, My question.

 

Only 'Const' can be saved in flash memory? Or  can be delete or not? The flash erase sequence doesn't operate. The variable "test" value can't be modified in flash??

 

How can I modify this value(test) in flash memory?

 

<lcf>

MEMORY

{

    resetvector:        org = 0x00000000,   len = 0x00000008

    init:               org = 0x00000020,   len = 0x00000FE0

    exception_handlers: org = 0x00001000,   len = 0x00001000

    internal_flash:     org = 0x00002000,   len = 0x00160000

 

    my_Flash:   org = 0x00160000, len = 0x0001E000

 

    internal_ram:       org = 0x40000000,   len = 0x0000A000

    heap  :             org = 0x4000A000,   len = 0x00002000 /* Heap start location */

    stack :             org = 0x4000C000,   len = 0x00004000 /* Start location for Stack */

}

.

.

SECTIONS
{
    .__bam_bootarea LOAD (0x00000000): {} > resetvector

    GROUP : {
      .init LOAD (0x00000020) : {}
      .init_vle (VLECODE) LOAD (_e_init) : {
        *(.init)
        *(.init_vle)
      }
    } > init

    .__exception_handlers  LOAD (0x00001000): {} > exception_handlers

    GROUP  : {
        .text : {}
        .text_vle (VLECODE) ALIGN(0x1000): {
             *(.text)
             *(.text_vle)
         }
        .rodata (CONST) : {
            *(.rdata)
            *(.rodata)
        }
        .ctors : {}
        .dtors : {}
        extab : {}
        extabindex : {}
    } > internal_flash
   
    .__my_Flash LOAD(0x00160000):{}>my_Flash

    GROUP : {
       .__uninitialized_intc_handlertable ALIGN(0x10) : {}
       .data   : {}
       .sdata  : {}
       .sbss   : {}
       .sdata2 : {}
       .sbss2  : {}
       .bss    : {}
    } > internal_ram
}

 

<.c file>

#pragma push

#pragma section all_types ".__my_Flash" ".__my_Flash"

uint32_t test=0x1000;

#pragma pop

 

<write sequence>

 

unsigned int* b = (unsigned int*)address;

 

FLASH.MCR.B.PGM = 1;

 

test = data;

add=&test;

FLASH.MCR.B.EHV = 1;

while(FLASH.MCR.B.DONE == 1){};

FLASH.MCR.B.EHV = 0;
 
FLASH.MCR.B.PGM = 0;

 

 

<Result>

&test = 0x00160000

*test = 0x1000

 

But I can't modify this variable's value.

Outcomes