Originally Posted by
Salem
The compiler is able to see where the variable is modified, so it is able to do the right thing.
I didn't get this point
By changing the code to mode didn't work eithier
Code:
unsigned int once =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)
{
vPrintf("\r\ncheck the volitality in sw_later once :%d",once);
once = 1;
vPrintf("\r\ncheck the volitality in later once :%d",once);
//Will create a timer
(void)CreateTimer(Timer_handler, &u8Msg1, 0, 200, &u8TimerId1);
}
main()
{
(void)CreateTimer(Timer_handler, &u8Msg1, 0, 200, &u8TimerId1);
while(1)
if(once)
{
switch(State)
{
case TX_ST:
//SendData();
State = RX_ST;
break;
default:
vPrintf("\n\rdefault");
break ;
}
once = 0; Is this what you mean by detecting modifications ?
}
}
Ouput :
check the volitality in sw_later once = 0
check the volitality in later once = 1
My code survied without being declared "once"as volatile.