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.

MSP430FR2433: Shall a variable made PERSISTENT() or NOINIT() be specified as volatile?

Part Number: MSP430FR2433

When declaring a variable and making it PERSITENT() or NOINIT(), shall we specify the variable as volatile?

  • Hi Thomas,

    It depends on how the variables will be used.

    A variable should be declared volatile whenever its value could change unexpectedly. In practice, only three types of variables could change:

    • Memory-mapped peripheral registers (peripheral registers)
    • Global variables modified by an interrupt service routine
    • Global variables within a multi-threaded application

    PERSISTENT or NOINIT pragmas apply to variables located in non-volatile memory, FRAM in this case, and are typically protected with a write protection mechanism.  But if you have a PERSISTENT or NOINT variable that can be modified in the main thread and the ISR, you should still probably qualify them as volatile to be on the safe side.

  • Thank you Dennis. Keep up the good work.

**Attention** This is a public forum