Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/20/04 11:09
Read: times


 
#81567 - Timer event detection
hi

Here is my my code.


main()
{

startTimer2()


while(1)
{

//some long process here



//In the last i want to check that Timer1 has counted 50
//millisecond interval
if(TF1 == 0)
{
//do some processing here at every 50 milliseconds

//again start 50 millisecond timer
startTimer2();
}

}
}



void startTimer2(void)
{
//start 50 millisecond timer
TR1 = 0;

TH1 = 0x4B;
TL1 = 0xFD;

TF1 = 0;
TR1 = 1;
}






the problem above code is execution never goes in the IF block.

if(TF1 == 0)
{

}


it seems that after counting for 50 milliseconds... timer is still running and TF1 never goes 0 exception at the exact moment when Timer registers reaches 0. but as timer is still running so it keeps detecting from the registers. but as you can see i am doing a executing C statements above IF statement so TF1 is never 0 wheneven i check the TF1.

what i want is that when timer has counted and registers are reduced to 0 then it should stop counting so TF1 should be 0 when i read its value

Many thanks
Shahzad Aslam

List of 2 messages in thread
TopicAuthorDate
Timer event detection            01/01/70 00:00      
   Timer Event Detection            01/01/70 00:00      

Back to Subject List