Fra: lpc2000@lpc2... [mailto:lpc2000@lpc2...] Pvegne af
dodge1955
Sendt: 8. december 2005 17:51
Til: lpc2000@lpc2...
Emne: [lpc2000] LPC2138 Timer0 Interrupt
Can anyone tell me why my interrupt is not firing? The T0IR flag is
set upon rollover of the TIMER0 32 bit timer, but my code is not
vectored to the interrupt code. My variable 'system_timer' never
gets
decremented.
unsigned long system_timer, j;
void decrement_timers() __irq
{
// occurs 896 times per second
system_timer--;
T0IR |= 1;
}
int main()
{
VPBDIV = 1;
// set up delay timer (TIMER 0)
VICIntSelect = 0; // all interrupts classified as IRQs
VICVectCntl0 = 0x00000024;
VICVectAddr0 = (unsigned int) decrement_timers;
VICIntEnable = 0x00000010;
Make sure your global IRQ flag is clear, (I_BIT in CPSR needs to be
0). Also you need to clear the VICVectAddr (VICVectAddr = 0x00000000)
at the end of your interrupt.
Other then that it should work, however if wont occur 896 times per
second, more like once every 71s with a 60Mhz PCLK.
Mark
--- In lpc2000@lpc2..., "dodge1955" <sutton@h...> wrote: >
> Can anyone tell me why my interrupt is not firing? The T0IR flag is
> set upon rollover of the TIMER0 32 bit timer, but my code is not
> vectored to the interrupt code. My variable 'system_timer' never
gets
> decremented.
>
> unsigned long system_timer, j;
>
> void decrement_timers() __irq
> {
> // occurs 896 times per second
>
> system_timer--;
>
> T0IR |= 1;
> }
>
> int main()
> {
> VPBDIV = 1;
>
> // set up delay timer (TIMER 0)
>
> VICIntSelect = 0; // all interrupts classified as IRQs
> VICVectCntl0 = 0x00000024;
> VICVectAddr0 = (unsigned int) decrement_timers;
> VICIntEnable = 0x00000010;
>
> // Disable Timer0 and Reset Interrupt Flag
>
> T0TCR = 0;
> T0IR |= 1;
>
> T0MR0 = 0;
> T0MCR = 1;
>
> T0CTCR = 0;
> T0PR = 0;
> T0TCR = 1;
>
> // just an infinite loop to check Timer0
>
> system_timer = 4000;
>
> j = 0;
> for(;;)
> {
> j = j + 2;
> }
>
Reply by Randy Ott●December 8, 20052005-12-08
Maybe interrupts are not enabled?
--- In lpc2000@lpc2..., "dodge1955" <sutton@h...> wrote: >
> Can anyone tell me why my interrupt is not firing? The T0IR flag is
> set upon rollover of the TIMER0 32 bit timer, but my code is not
> vectored to the interrupt code. My variable 'system_timer' never
gets > decremented.
>
> unsigned long system_timer, j;
>
> void decrement_timers() __irq
> {
> // occurs 896 times per second
>
> system_timer--;
>
> T0IR |= 1;
> }
>
> int main()
> {
> VPBDIV = 1;
>
> // set up delay timer (TIMER 0)
>
> VICIntSelect = 0; // all interrupts classified as IRQs
> VICVectCntl0 = 0x00000024;
> VICVectAddr0 = (unsigned int) decrement_timers;
> VICIntEnable = 0x00000010;
>
> // Disable Timer0 and Reset Interrupt Flag
>
> T0TCR = 0;
> T0IR |= 1;
>
> T0MR0 = 0;
> T0MCR = 1;
>
> T0CTCR = 0;
> T0PR = 0;
> T0TCR = 1;
>
> // just an infinite loop to check Timer0
>
> system_timer = 4000;
>
> j = 0;
> for(;;)
> {
> j = j + 2;
> }
>
Reply by dodge1955●December 8, 20052005-12-08
Can anyone tell me why my interrupt is not firing? The T0IR flag is
set upon rollover of the TIMER0 32 bit timer, but my code is not
vectored to the interrupt code. My variable 'system_timer' never
gets
decremented.
unsigned long system_timer, j;
void decrement_timers() __irq
{
// occurs 896 times per second
system_timer--;
T0IR |= 1;
}
int main()
{
VPBDIV = 1;
// set up delay timer (TIMER 0)
VICIntSelect = 0; // all interrupts classified as IRQs
VICVectCntl0 = 0x00000024;
VICVectAddr0 = (unsigned int) decrement_timers;
VICIntEnable = 0x00000010;