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.

using Info memory for variables

Ladies and Gents,

I'm sure you've seen this topic a million times, and I have searched and searched for an exact answer for my question, but hit my head a few times.

I dabble with MSP430 to drive some of TI's audio devices. I want to be able to able to UART from my PC into the 430 that is on the launchpad and update some variable, and store those variables, so that next time I power up the board, the new saved settings are used.

The UART bit I got working, thanks to some excellent code from 430oh, but I'm still a complete amateur when it comes to storing those updated coefficients in non-volatile memory. I have 8 coefficients that I need to store, so INFOB seems ideal.

I only need to initialise them to preset values once, after that, updated will only be done by UART, with multiple power up power downs happening in between. That's what throws me. How do guarantee that the initialization only happens once in it's lifetime?

I've seen some code on the e2e that suggests that I set up variables like this:

#pragma DATA_SECTION(myvariablename, ".infoB");
Int myvariablename = 0x07;
(please correct me if I'm wrong)
If that's in my main C file, how do I stop it from resetting whatever new settings I have back to 0x07 whenever I cycle power?
Also, is that all I need to do to treat "myvariablename" as a non-volatile variable?
I hope I'm making sense. And yes, I'm a complete noob when it comes to C & Microcontrollers :)
Cheers
Rochey
  • The code you got should work. It places the variable into INFOB memory and you can read it like any other. However, any write attempt (even though it will not cause a compiler error) will fail, as the flash will simply ignore the write.
    The init value, as compiled, will be written to the info memory together with the application. It won’t be reset at power cycle. But it is read-only and future changes need to follow a special sequence:

    Copy all values you want to keep from INFOB into ram (e.g. local variables)
    Program the flash controller for a segment erase and erase INFOB
    Program the flash controller for single write mode
    Write the new values (and any old values you saved and still need) to INFOB
    Lock the flash controller.

    The new values are then saved in INFOB and again read-only.

    How to write to flash is covered in many older threads.

**Attention** This is a public forum