We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
We are using 89C51RD2 with standard 12 clock stand mode, in this Timer 0 we are initializing with following snapshot code and expected to fire interrupt for every 10mSeconds approx.:
INI_TIMER0() { TMOD &= 0xF0; TMOD |= 1; TL0 = 0xE5; TH0 = 0xBE; ET0 = 1; TR0 = 1; }
But when I check firing intervel in one of the port line by using CRO I am getting 40 mSeconds. to check I used following code:
void Timer0Handler(void) interrupt 1 using 3 { static unsigned char flag = 0; EA = 0; if(flag == 0) { CEX0 = 1; flag = 1; } else { CEX0 = 0; flag = 0; } }
I changed TH0 and TL0 values several times and tested. Irrespective of my reload vales I am getting signal level change in CEX0 port line always 40mSeconds.
What's the wrong with my code? Appreciate your help.
Additional Info:
Using 20 MHz Crystal. End of void Timer0Handler(void) interrupt 1 using 3 routine reenabling all Interrupts.