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.

MSP430FR6989: How to avoid debugger erasing "Persistant" data in FRAM which is intended to be NV (EEPROM)

Part Number: MSP430FR6989
Other Parts Discussed in Thread: MSP430WARE,

Hi,

My customer wants to use half of the FRAM available in the device as EEPROM. They want to use this space for data-logging in their application. But whenever they enter the debug mode either through IAR or CCS, the data gets completely erased. Is there a way to prevent this from happening?

Regards,

Chander

  • Um, is that how they're spelling it? (Should be "PERSISTENT" [Ref CC430 UG (SLAU132U) Sec 5.12.22])

    I'm not just being picky -- as I recall a C compiler is required to ignore unrecognized #-pragma options, so it may be silently inoperative.

    [Edit: Perhaps a code fragment would be enlightening.]

  • Hi,

    No the spelling is correct. It's a typo from my side.

    You can easily reproduce the issue through the code example: C:\ti\msp\MSP430Ware_3_80_07_00\fram_utilities\examples\nvs\IAR\nvs_ex3_datalog

    Regards,

    Chander

  • > whenever they enter the debug mode either through IAR or CCS

    Sorry, I missed this clause. PERSISTENT variables are re-initialized when the code is loaded, but not on a reset. To survive a code download, you need NOINIT. [Ref C compiler UG (SLAU132U) Sec 5.12.22]

  • When we use NOINIT, those variables do not go to FRAM. They are stored in regular RAM. So this doesn't help.

  • To move NOINIT from RAM to FRAM, you need to change the linker file.

    Remove this line (line 191 in my copy of lnk_msp430fr6989.cmd):

      .TI.noinit  : {} > RAM                  /* For #pragma noinit                */
    
    

    and insert it (slightly changed) after .TI.persistent (line 137 in my copy):

    .TI.persistent : {} /* For #pragma persistent */
    .TI.noinit : {} /* For #pragma noinit */
    .cio : {} /* C I/O Buffer */
    
    
    
    

    Since you want to use a large space, you may need to change the MPU definitions ("Build Settings->CCS General->MPU" tab) since it looks like the default layout only gives you about 2KB read/write.

    This will give you a little less than 48KB (low FRAM) to work with. If you need more, you probably need to work with high FRAM (FRAM2 region) which requires a little more fiddling.

    I don't have an FR6989 to work with here, but the .map file seems to say I've succeeded by doing this.

  • Hi, Chander, 

    You need to use debug without download function to no erasing and initializing the variables. 

    For IAR, you can find there is Menu button "debug without download". 

    For CCS, please refer to this post for the debug without download: https://e2e.ti.com/support/tools/ccs/f/81/t/538495?How-to-debug-existing-code-in-CCS-without-flashing-a-new-code- . Or you can see the video directly: quick tip video.

    Thanks, 

    Lixin

  • Hi Lixin,

    "Download without Debug" won't work as it will not update the program also. The customer need to update/debug the source code but in the process don't want to loose the stored NV data.

    Regards,

    Chander

  • Did changing to NOINIT, along with the linker file (and maybe the MPU) help?

    Stating the obvious: NOINIT really means "no initialization". The first time you load the code, there is likely to be stale (or nonsense) data in that area, which CTPL may or may not deal well with. Detecting the "first time" condition is, um, "left as an exercise". (I usually use a CRC.)

  • No, the moment I change the allocation of NOINIT space to FRAM, they start getting erased when entering the debug mode. My changes in the xcl file reflected below:

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    / ---------------------------
    // Memory Protection Unit (MPU) border
    //

    -Z(CONST)MPU_B2

    // ---------------------------
    // Constant data
    //

    -Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=4400-FF7F
    -Z(DATA)DATA16_N,DATA20_N=4400-FF7F
    // ---------------------------
    // Code
    //

    -Z(CODE)CSTART,ISR_CODE,CODE16=4400-FF7F


    // -------------------------------------
    // All memory 0-FFFFF
    //

    -----------------------------------------------------------------------------------------------------------------------------------------------

    Regards,

    Chander

  • I looked at the source code for the interface between mspdebug and the TI debug library and found several variations of the erase function. Besides an erase main memory there is also an erase segment. So it appears possible to do what you want.

    But I can't think of any tools that use the erase segment function. Programming the device will always erase all of main memory. Expecting user data to survive that is a mistake so if you wish to preserve that data you must read it and store it on the host.

    I suppose if you were motivated enough you could use the mspdebug source code as a base and modify it to only erase the space being programmed. Or skip the erase step completely for FRAM parts.

  • I haven't used IAR in some time, but it used to have an option to "erase only changed segments" or some such. I used that back in the F2 days to preserve parameter data in (non-Information) Flash.

  • Hi, Chander, 

    There is a Flash erase option in the Run->Debug Configurations... menu. For MSP430FR6989, if you want to use half of the FRAM memory for data logging and other half FRAM memory for code, and debugging/programming without data logging area erased, you can try the last option: By address range. 

    Thanks, 

    Lixin 

  • Hi, Chander, 

    Does my answer help you to resolve the issue? 

    Thanks, 

    Lixin 

  • Hi Lixin,

    I have not checked it yet. I will let you know soon.

    However, my customer uses IAR. Is there anything similar possible in IAR?

    Regards,

    Chander

  • I haven't used IAR in some time, but it used to have an option to "erase only changed segments" or some such. I used that back in the F2 days to preserve parameter data in (non-Information) Flash.

  • Hi, Chander, 

    Bruce is right. IAR has similar Erase options too. But it is some different from CCS. 

    Right click the project in IAR -> Options -> FET Debugger. You can find the Erase options like following figure. 

    Thanks, 

    LIxin 

  • Lixin, Bruce,

    Thanks for the inputs. These have been provided to the customer. I am waiting for their feedback. 

    Regards,

    Chander

**Attention** This is a public forum