4.3.4.2 How Do I Retain the Value of a Variable Even After a Soft Reset?

First, consult your device data sheet to see which Resets are available. Then save the values of your variables after a software Reset, using the persistent attribute, which specifies that the variable should not be initialized or cleared at startup. For more on this attribute, see the following section in this user’s guide:

9.10 Variable Attributes