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.

Store data in Flash memory

Other Parts Discussed in Thread: MSP430F1132, MSP430F2274, MSP430F2252

Hi,

 

I am a newbie to MSP430 and am considering using msp430f1132 which has a flash of 8k. Actually I want to store the data that I periodically sample in Flash memory and extract them after sometime.

 

Can anybody,pls tell me how to use the flash as a data store in msp430.

 

Thanks

 

Janaka

  • Hi Janaka,

    have a look at this post: http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/p/18663/71969.aspx#71969.

    The functions presented there work fine (and it also contains some other information which might be useful for you). The example presented uses MSP430F2274 but it explains how to write to flash memory.

    Rgds
    aBUGSworstnightmare 

  •  

    I made a sort of datalogger for MSP430F2252 which should works like the serie 1 (made in speed so it is not really good written but it works for the need I have).

     There is a lot of really good information on user guide, and perhaps try to look at some code example.

     

    This is the method I use to write on flash

    ;------------------------------------------------------------------------------
    ; Write on flash
    ;------------------------------------------------------------------------------
    ; Input: ADCresult, value to write at address R8
    ;------------------------------------------------------------------------------
    WriteFlash:
    dint ;Disable interrupts
    mov.w #FWKEY+FSSEL1+FN0,&FCTL2 ;SMCLK/2
    mov.w #FWKEY,&FCTL3 ;Clear lock
    mov.w #FWKEY+WRT,&FCTL1 ;Enable write
    mov.w ADCresult,0(R8) ;Write ADC10MEM @ address
    mov.w #FWKEY,&FCTL1 ;Write done, clear WRT
    mov.w #FWKEY+LOCK,&FCTL3 ;Set lock
    eint ;Enable interrupts
    ret

     

    each two minute I call this function from MAIN

    [...]
    call #WriteFlash
    incd.w R8
    cmp.w #StopAddr,R8
     jl Continue
    ;---- Stop data mining
    bis.w #LPM4,SR
     [...]

     

    And R8 is initialized (at power on) like that:

    mov.w    #StartAddr,R8

     

    And finally the parameters for the reserved space:

    StartAddr EQU 0C200h
    StopAddr EQU 0FF00h

**Attention** This is a public forum