what are the implications of volatile....
Hi,
Code:
unsigned int value=0; //Following is my declarations
//Following is my timer handler which will be executed every 0.2 seconds
void Timer_handler(void* pvMsg, uint8 u8MsgLen)
{
///To check the volitality of the variable
if(value<254)
{
vPrintf("\r\ncheck the volitality value :%d",value);
value++;
}
else
{
value = 0;
}
once = TRUE;
//Will create a timer
(void)CreateTimer(Timer_handler, &u8Msg1, 0, 200, &u8TimerId1);
}
Here i have declared the variable "value" as normal automatic varibale.
and the ouput is :
1
2
Why is it that the compiler not optimising the variable?
Isn't this(timer handler) main usage of volatile variable?
Thanks