This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Doubts on Timer 0 & Timer 1 of 89C51, Timer 2 of 89C52

For Timer 2 of 89C52, to initialise it, the routines i used are as follow:

void setTimer2 (void)
{
TR2=0;
count20ms=0;
T2CON=0;
RCAP2H=(-40000) >> 8;
RCAP2L=(-40000) & 0x0ff;
TH2=RCAP2H;
TL2=RCAP2L;
TF2=0;
ET2=1;
EA=1;
}

if i were to use Timer 0, is the routine i used below correct??? -->

void setTimer0 (void)
{
TR0 = 0;
count20ms = 0;
TMOD = (TMOD & 0xf0) | 1;
TH0 = (-40000) >> 8;
TL0 = (-40000) & 0x0ff;
TF0 = 0;
ET0 = 1;
EA = 1;
}

If the above routine for Timer 1 initialization is wrong, can someone tell me what is wrong and what i should write???

Last question, i used Timer 2 as a timer (to keep track of something). If i were to use Timer 0 or Timer 1, can i still use it as a timer like Timer 2. If yes, which mode should i used???

thanks...

0