When declaring a variable and making it PERSITENT() or NOINIT(), shall we specify the variable as volatile?
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.
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:
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.
**Attention** This is a public forum