This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR5959: Unable to write data in FRAM

Part Number: MSP430FR5959


Tool/software:

when variable is declarer as a as shown in below code  but unable to write data on same variable .looking forward to your help.

#pragma NONINIT(demo_config)
unsigned char demo_config[2] ={1};

typedef struct{
unsigned char a;
unsigned char b;
}DEMO_CIONFIG;
DEMO_CIONFIG gost_demoConfig;

gost_demoConfig.a =5;
memcpy(&demo_config, &gost_demoConfig,sizeof(gost_demoConfig));
gost_demoConfig.a = 0;
memcpy(&gost_demoConfig, &demo_config,sizeof(demo_config));

putch1(((gost_demoConfig.a)/100)%10 +'0');
putch1(((gost_demoConfig.a)/10)%10 + '0');
putch1((gost_demoConfig.a) %10 +'0');

after every power on getting 255 as gost_demoConfig.a

  • If you haven't changed the linker (.cmd) file, NOINIT variables (section .TI.noinit) are placed in RAM. [I'm assuming you meant NOINIT since "#pragma NONINIT()" would be ignored.]

    If you have changed the linker file, please describe the changes since you may (or may not) need to involve the MPU.

  • i changed in linker(.cmd) but still not able set value ,looking forward to your help.

  • Please describe your changes to the .cmd file.

    I tried your code on an FR5969 (Launchpad) and observed:

    1) "#pragma NONINIT" was indeed ignored (with a Warning), and demo_config was put in RAM (.data).

    2) Changing it to "#pragma NOINIT" got a different Warning about the initialization ("={1,}") and -- more to the point -- it apparently ignored the NOINIT specification and put demo_config in RAM (.data).

    3) Removing the initialization put demo_config in .TI.noinit (still in RAM).

    4) Changing the linker file to move the ".TI.noinit" line down to the write-able area at the bottom of FRAM (next to .TI.persistent) put demo_config in FRAM and allowed me to write it.

    The .cmd fragment now looks like:

            GROUP(READ_WRITE_MEMORY)
            {
               .TI.persistent : {}              /* For #pragma persistent            */
               .TI.noinit  : {}                 /* For #pragma noinit                */
               .cio           : {}              /* C I/O Buffer                      */
               .sysmem        : {}              /* Dynamic memory allocation area    */
            } PALIGN(0x0400), RUN_START(fram_rw_start)
    

    5) Setting Project->Properties->Debug->MSP430 Flash Settings->Erase Options to "necessary segments only" allowed me to retain demo_config over a code download.

    [Edit: Minor clarification.]

  • Hello Namita - did Bruce's suggestion work for you?

  •  we did this changes in .cmd file

  • but its not working yet

  • This change puts the NOINIT section in read-only FRAM, while step (4) above puts it in write-able FRAM. And without steps (2)-(3) your variable won't be put in that section anyway.

    I suggest you make all of the changes I described, i.e. (a) change NONINIT->NOINIT (b) remove the initializer (c) move .TI.noinit into the READ_WRITE_MEMORY group (d) change the "Erase Options" so re-loading the code won't erase the NOINIT section.

  • we made changes as per attached image and to verify its working or not  we write syntax as below 

    #pragma NOINIT(demo_config)
    unsigned char demo_config[2] ={};

    gost_demoConfig.a =5;
    memcpy(&demo_config, &gost_demoConfig,sizeof(gost_demoConfig));
    gost_demoConfig.a = 0;
    memcpy(&gost_demoConfig, &demo_config,sizeof(demo_config));

    putstr1("\nu16_TimePM:");
    putch1(((gost_demoConfig.a)/100)%10 +'0');
    putch1(((gost_demoConfig.a)/10)%10 + '0');
    putch1((gost_demoConfig.a) %10 +'0');

  • What results did you see?

    Did you get a Warning about the initializer for demo_config[]? (Maybe a null initializer is different somehow.)

**Attention** This is a public forum