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.
Hi, i want to tune my timer ISR to 20hz , 1/20 sec , i dont know what are the values to be loaded with the timer.
void timer0_isr (void) interrupt 1 using 1 { unsigned i; TR0 = 0; /* stop timer 0 */ TL0 = ; TH0 = ; TR0 = 1; overflow_count++; }
50ms at 11.49MHz
50e-3/ (1 / ((11.49 * 1e6) / 12)) = 47875
Reload value = 65536 - 47875 = 17661
Reload HI = 17661 / 256 = 0x44 = 68 Reload LO = 17661 % 256 = 0xFD = 253
thanks i got the idea is this correct to make ISR at 15ms ~ 15hz ?
static unsigned long overflow_count = 0; void timer1_ISR (void) interrupt 3 { overflow_count++; /* Increment the overflow count */ } /*------------------------------------------------ MAIN C function ------------------------------------------------*/ void main (void) { Set the Timer1 Run control bit. --------------------------------------*/ TMOD &= 0xF0; // Clear all T0 bits (T1 left unchanged) TMOD |= 0x01; TH1 = 0xC5; TL1 = 0x68; ET1 = 1; /* Enable Timer 1 Interrupts */ TR1 = 1; /* Start Timer 1 Running */ EA = 1; /* Global Interrupt while (1) { } }