--- In lpc2000@yahoogroups.com, "mhaines4102" <mhaines4102@y...>
wrote:
>
> I have a dumb question. I am embarrassed to ask but... I am using a
> timer interrupt. My setup is as follows:
> /* Timer 0 interrupt is an IRQ interrupt */
> VICIntSelect &= ~(0x10);
> /* Enable timer 0 interrupt */
> VICIntEnable = (0x10);
> /* Use slot 0 for timer 0 interrupt */
> VICVectCntl0 = 0x24;
> /* Set the address of ISR for slot 0 */
> VICVectAddr0 = (unsigned long)timer0ISR;
> /* Reset timer 0 */
> T0TCR = 0;
> /* Set the timer 0 prescale counter */
> T0PR = 2500;
> /* Set timer 0 match register */
> T0MR0 = 1000;
> /* Generate interrupt and reset counter on match */
> T0MCR = 3;
> /* Start timer 0 */
> T0TCR = 0x01;
> T0IR = 0xFF;
>
> The interrupt was being called, then it stopped. I changed some
> settings and it came back, then it stopped again. I added T0IR =
0xFF;
> to the end of the setup and it worked, then it stopped again. What
> have I missed? I am beginning to feel like a goof.
>
> Thanks,
>
> Mike Haines
>
I have Timer0 interrupt 2000 times per second using a prescale of 2
and a count of 14400. Besides toggling an LED, it increments a tick
counter for the uIP (TCP/IP) stack - specifically for telnet.
Here is my Timer0 setup (setup.c):
// set up Timer 0
TIMER0_TC = 0; // clear the timer count
TIMER0_PR = 1; // prescale divide by 2
TIMER0_MR0 = 14400; // divide by 14400 to get 2048 ints per second
TIMER0_MCR = 0x03; // interrupt on match, reset on match
TIMER0_TCR = 0x01; // start the timer
VICVectCntl3 = 0x00000024; // set priority 3 for Timer 0
VICVectAddr3 = (unsigned long) T0ISR; // pass the address of the ISR
VICIntEnable = 0x00000010; // enable interrupt
This is my interrupt routine (interrupt.c):
void T0ISR(void)
{
ticks++;
if ((ticks & 0x07FF) == 0) // every 2048 ticks
{
if (ticks & 0x0800) // every 4096 ticks
IOSET = LED_YELLOW;
else
IOCLR = LED_YELLOW;
}
TIMER0_IR = 0x01;
VICVectAddr = 0xFF;
}
Here is my interrupt routine prototype (interrupt.h):
void T0ISR (void) __attribute__ ((interrupt));
The only other changes I have made is to increase all of the stacks
to 64 bytes from 4. Not necessary perhaps, but safe.
Richard