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.

MSP430F249: MSP430F249

Part Number: MSP430F249


how to retain the change in variable value after switching off the microcontroller in flash memory, I tried to declare it globally but no use any other options available

  • Hi,

    The global variable is saved in RAM and not in flash. When it power on, it will initialize the variable.

    If you want to save the value, you need to write to flash memory at last.


  • Hi,

    From the MSP430userguide i found a sample program for writing in flash memory which is in assembler language

    L1 BIT #BUSY,&FCTL3 ; Test BUSY
    JNZ L1 ; Loop while busy
    MOV #FWKEY,&FCTL3 ; Clear LOCK
    MOV #FWKEY+WRT,&FCTL1 ; Enable write
    MOV #0123h,&0FF1Eh ; 0123h -> 0FF1Eh
    L2 BIT #BUSY,&FCTL3 ; Test BUSY
    JNZ L2 ; Loop while busy
    MOV #FWKEY,&FCTL1 ; Clear WRT
    ... ; Re-enable WDT?

    Is there a sample program in C language,  or how to declare the address in c

  • Example msp430x24x_flashwrite_01.c demonstrates writing flash. It works with 64 bytes, but you can change that.

    Be a little careful with this example. It writes the same flash location(s) repeatedly without pause. So don't let it just run, rather stop it after one pass using a breakpoint. It will wear out the flash in (as I recall) about a half-hour.