Declaration as VOLATILE

Language reference ›› Variables ››
Parent Previous Next

A variable may be declared as VOLATILE; this means that the optimizer will never optimize this variable due to  the knowledge of it's content, as it can change at any time between two Pascal statements.


VAR
 IntCount: VOLATILE BYTE; // Can change in interrupt


VOLATILE does not mean “atomic”: if the variable is of a type greater than one byte, PMP does not care if one byte may be modified between two PIC instructions. It is up to the programmer to code special constructions to avoid atomic problems on variables that are used under interrupt servicing.