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 0 Interrupt

Hi

I am trying to use a Timer 0 as a 16-bit Timer to generate an Interrupt every 10 ms. In this example (downloaded from keil), the Interrupt is generated every 65536 clocks

My question is how would i modify the example so that the interrupt is generated not according to the clock cycles, but rather by how much time passed away?

Do I have to prescale the clock that is benig feed to Timer 0? if so, how?

static unsigned long overflow_count = 0;

void timer0_ISR (void) interrupt 1
{
overflow_count++; /* Increment the overflow count */
}

void main (void)
{

TMOD = (TMOD & 0xF0) | 0x01; /* Set T/C0 16-bit Timer Mode */
ET0 = 1; /* Enable Timer 0 Interrupts */
TR0 = 1; /* Start Timer 0 Running */
EA = 1; /* Global Interrupt Enable */

while (1)
{
}
}

0