Elaborating on WHY it needs to be volatile is that it's basically a hint to the compiler not to cache the data / variable in a register as it will most likely be modified externally.
5
Sigiloso
21 de mar. de 2010
The variable which needs to be updated very often then that variable should be declared as volatile. The variables that need to updated based on interrupt then that variable should be defined as volatile. Ex:time, whenever interrupt occurs for time the clock tick increments which will be declared as volatile.