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

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

Children
No data