lats
Full Member level 4
89s52 timer2 problem
hi,
I'm trying to toggle a led's state on timer2 overflow interrupt. But the code dosen't seem to work. Frequency at which led blinks (blinking may not be even visible) is not important. Below is the code:-
& one thing more how will be the frequency calculated will it be Freq = Xtal Freq / (C*12 * 2)
waiting for your help.... thnx
hi,
I'm trying to toggle a led's state on timer2 overflow interrupt. But the code dosen't seem to work. Frequency at which led blinks (blinking may not be even visible) is not important. Below is the code:-
Code:
void timer2_ISR (void) interrupt 5 using 1
{
OverFlowTimer2++;
if(OverFlowTimer2>=10)//1 seconds
{
OverFlowTimer2=0;
TF2=0;
led=!led;
}
}/////end of timer0_ISR
T2CON=0x00;
T2MOD=0x01;
TL2 = 0x00; // Timer 2 low byte
TH2 = 0xFF; // Timer 2 high byte
RCAP2L = 0x00; // Timer 2 reload capture register, low byte
RCAP2H = 0xFF; // Timer 2 reload capture register, high byte
TR2 = 1;
& one thing more how will be the frequency calculated will it be Freq = Xtal Freq / (C*12 * 2)
waiting for your help.... thnx