use the search function:
In short: it's used if a variable or register can change it's value outside a specific program location, e.g. an IO port or a variable which is changed in an ISR.
The keyword "volatile" tells the compiler not to optimize this code, so the variable's or register's value is really determined again. Example:
Code:
volatile int counter;
void TimerInterrupt(void) // interrupt service routine triggered e.g. by timer interrupt
{
counter++;
}
void main(void)
{
counter = 0;
while(1)
{
if (counter == 5) DoSomething(); // without volatile declaration this line wouldn't be processed as counter isn't changed here
}
}