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.

MSP430FR69891: Placing variables in FRAM

Part Number: MSP430FR69891
Other Parts Discussed in Thread: MSP430FR6989

Hello,

I'm having difficulty placing variables in FRAM.  I'm using the documented technique using the #pragma PERSISTENT feature of the compiler.  When I do this, the variable is placed in RAM, not FRAM.  Here's an example of the code I'm using:

#pragma PERSISTENT( FRAM_write )
//#pragma location = 0x4400;
unsigned long FRAM_write[ 128 ];

This places FRAM_write in RAM, as seen from the memory map:

 output                                  attributes/
section   page    origin      length       input sections
--------  ----  ----------  ----------   ----------------
.bss       0    00001c00    0000059a     UNINITIALIZED
                  00001c00    00000200     (.common:FRAM_write)

However, when I use #pragma location to set the location of the variable in FRAM (e.g. at location 0x4400), then it is placed in FRAM.

#pragma PERSISTENT( FRAM_write )
#pragma location = 0x4400;
unsigned long FRAM_write[ 128 ];

Here's the memory map, for the above code:

.TI.bound:FRAM_write
*          0    00004400    00000200     UNINITIALIZED
                  00004400    00000200     main.obj (.TI.bound:FRAM_write)


The only disadvantage of the using #pragma location, is that the FRAM_write buffer is now stepping on some code, since now the code crashes when the buffer is written to using the following test code,
which is executed immediately in main().

    memset( FRAM_write, 0xA5, sizeof( FRAM_write ) );

Possibly this is a compiler issue?  I'm using msp430_16.9.4.LTS and CCS 7.2.0.

Any help with this issue would be greatly appreciated.

Thanks,
Adam

  • Hi Adam,

    you are using PERSISTENT but didn't initialize FRAM_write, I guess there is a warning for this when you compile it.

    if check the Ink_msp430fr6989.cmd file you will find persistent will be allocated in FRAM but TI.noinit is allocated in RAM.

    please try below code:

    unsigned long FRAM_write[ 128 ] = {0};

    regards
    KC
  • Hi KC,

    Thanks for your help.  Adding the initialization to the variable is what solved the problem.  I was missing that in my code.

    Thanks very much!

    Adam

**Attention** This is a public forum