Hello I use C51 with crystal 11.0592Mhz , my task is i want use timer/counter as event counter and display counter value the maximum count in 1 sec is 2500. is this possible with C51 if yes than please give some idea how it done or if you have sample code than please send me. Thank you.
i make it zero like x = TL1; CntCompare +=(TH1*256)+x; TL1 = 0; TH1 = 0;
i make it zero like
You answered a different question than you were asked.
It's not about "making" it zero, it's about what happens if, e.g., the timer rolls from 0x20ff to 0x2100, after you read the low byte, but before you read the high byte. Your code will then believe it 0x21ff.
It's somewhat unlikely that this causes your problem, though, because the time window for this error is really quite small, so it would not usually be hit every time round.
Which brings us back to the original problem statement. You said earlier that at 1500 Hz input you got the "wrong" value. But you didn't say what that value actually is, nor which result you think you should have got, or why. What did you get at 1450 Hz, when it still worked?
at 1450Hz after 1 sec it give 1450 counter value and at 1500Hz it give 418 counter value.yes for 1450Hz or lower than 1450Hz it work fine. and ya i'm nothing do with roll over , if you have idea how i resolve roll over than please give some hint. And Thanks for Rply.
And is there any ISR for counter. e.g. Timer0 we have isr void t0isr (void) interrupt 3 ? i have write the timer ISR for Timer0 but it not execute because Timer1 use as counter.