Persistent Type Qualifier

The __persistent type qualifier is used to indicate that variables should not be cleared by the runtime startup code by having them stored in a different area of memory to other variables.

By default, C variables with static storage duration that are not explicitly initialized are cleared on startup. This is consistent with the definition of the C language. However, there are occasions where it is desired for some data to be preserved across a Reset.

For example, the following ensures that the static local object, intvar, is not cleared at startup:

void test(void)
{
static __persistent int intvar;  /* must be static */
// ...
}