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.

Starterware/MSP430FR6972: the question of allocating array to DATA20_P in the FRAM

Part Number: MSP430FR6972

Tool/software: Starterware

Hi Sir,

I want to store some arrays in the two DATA20_P segments of FRAM ,the DATA20_P is set in the lnkmsp430fr6972.xcl as following

// ---------------------------
// Read/write data in FRAM
//
-Z(CONST)DATA16_P,DATA20_P=D000-FF7F,10040-13FFF
-Z(DATA)DATA16_HEAP+_DATA16_HEAP_SIZE
-Z(DATA)DATA20_HEAP+_DATA20_HEAP_SIZE

// ---------------------------

I defined arrays as following

__persistent unsigned int CurrentFaultBuffer[5120] = {0x0000};
__persistent unsigned int ElecfieldFaultBuffer[5120] ={0x0000};

__persistent unsigned int Fault1Buffer[960] = {0x0000};
__persistent unsigned int Fault2Buffer[960] = {0x0000};

if the CurrentFaultBuffer[5120] was allocated to the 0xD000-0xFF7F, other's arrays were allocated to the 0x10040-0x13FFF, the space of  DATA20_P is enough. However ,I found all of arrays was allocated to the 0x10040-0x13FFF,so it is a mistake 

the question is How I could  allocate CurrentFaultBuffer[5120] to the segment DATA20_P(0xD000-0xFF7F) and allocate others to the segment DATA20_P(0x10040-0x13FFF) ?

Best regards

Jent

  • Hi Jent,

    5120 integer values is equivalent to 0x2800 bytes, which may not be enough to fit inside of the 0xD000-0xFF7F space (0x2F7F) if shared with your main code. Why are you using a custom linker file instead of the default, which utilizes the full lower memory model (0x4400-0xFF7F) and has more continuous space dedicated for persistent variables? I recommend leaving the large memory space (>0x10000) for code.

    Regards,
    Ryan
  • Thank you Ryan ,

    The 0xD000- 0xFF7F  only stored the DATA20_P ,  the main code  was stored in 6C00- CF7F.the whole .xcl is following:

    // ---------------------------
    // Read/write data in FRAM
    //
    -Z(CONST)DATA16_P,DATA20_P=D000-FF7F,10040-13FFF
    -Z(DATA)DATA16_HEAP+_DATA16_HEAP_SIZE
    -Z(DATA)DATA20_HEAP+_DATA20_HEAP_SIZE
    // ---------------------------
    // Constant data
    //
    -Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=6C00-CF7F
    
    // ---------------------------
    // ---------------------------
    // Code
    //
    -Z(CODE)CSTART,ISR_CODE,CODE16=6C00-CF7F
    
    // ---------------------------
    // Code
    
    -P(CODE)CODE=6C00-CF7F
    -Z(CODE)CODE_PAD
    
    // ---------------------------
    // ---------------------------
    // Constant data
    //
    -Z(CONST)DATA20_C,DATA20_ID,CODE_ID=6C00-CF7F
    
    // -----------------------------
    // Signature memory and interrupt vectors
    //
    
    -Z(CONST)SIGNATURE=CF80-CF8F
    -Z(CODE)INTVEC=CF90-CFFF
    -Z(CODE)RESET=CFFE-CFFF
    

    I put two programs(application program,upgrade program) in the FRAM,  the application program's .xcl file is mentioned above. the upgrade program is allocated to the 0x4400-0x6BFF in another .xcl file. so I must utilize 0x10040-0x13FFF  to store data

    Regards

    Jent

  • Hi Jent,

    It does appear that the compiler does not like splitting persistent between the lower and upper memory segments. Plus you will encounter issues with the MPU when you try to wrap the persistent variables around the interrupt vectors. Would it be possible to use the following memory map instead?

    Persistent variables: 0x4400 to 0xA2FF
    Upgrade code: 0xA300 to 0xCAFF
    Application code: 0xCB00 to FF7F, 0x10000 to 0x12F00

    This way the variables remain in the lower memory and code is split instead, which the linker/compiler appears to prefer.

    Regards,
    Ryan
  • Thank you Ryan ,
    You help me too much .Really appreciate your help!

    Regards,
    Jent

**Attention** This is a public forum