Hi,
I am using a global variables for producing timeouts as follows...
volatile tDByte TimerStart=0,TimerEnd=0,TimerInitiated=FALSE,Timeout=FALSE;
there are two tasks....task1:Clock and task2:OperateField which requires timeout...
void task3_Clock() _task_ TASK3 { while(1) { os_wait (K_IVL,200,0);/*500 ms interval*/ os_wait (K_IVL,200,0);/*500 ms interval*/ Seconds++; if(Seconds>=59) { Seconds=0; } if(TimerStart==TimerEnd) { TimerStart=0;TimerEnd=0; Timeout=TRUE; TimerInitiated=FALSE; } else { TimerStart++; } } } void task4_OperateField() _task_ TASK4 { while(1) { if(TimerInitiated==FALSE)/*If Timer is not fired then fire the timer*/ { Timeout=FALSE; TimerStart=Seconds; /*Read the current status of the SW clock*/ TimerEnd=Seconds+10; /*Set timer End as 10 seconds */ TimerInitiated=TRUE; /*Set flag as timer initiated */ } if(Timeout==TRUE) /*If 10 second timer expired */ { Point1=0x00; /*Then clear the command received*/ } }
in these two tasks are using the same variables.....TimerEnd,TimerStart,Timeout,TimerInitiated... These variables after time out it is initilized to some values in task3...but when returning to task 4 it restore the previous values....how to share the variables....kindly help me....