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

timer interrupt

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++;
}

Parents Reply Children
  • thanks for your reply , im using the usua 11.49 Mhz ,timer mode 16 bit with reload

  • 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)
      {
      }
    }