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

HI

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.

    Eason

  • Hi,

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

    MOV #WDTPW+WDTHOLD,&WDTCTL ; Disable WDT
    L1 BIT #BUSY,&FCTL3 ; Test BUSY
    JNZ L1 ; Loop while busy
    MOV #FWKEY+FSSEL1+FN0,&FCTL2 ; SMCLK/2
    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
    MOV #FWKEY+LOCK,&FCTL3 ; Set LOCK
    ... ; 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.

    http://dev.ti.com/tirex/explore/node?node=ACj45ei3w0K2qJIgvgGzgw__IOGqZri__LATEST

    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.

**Attention** This is a public forum