I'm trying to blink diode, using timer0 MR0 irq. The problem is that the irq works only one time. I see diode is just blinking once and nothing else.
I localized the issue and here's the code:
#include <lpc23xx.h> void t0_irq() __irq { if(T0IR&1) { T0IR=1;//reset irq if(FIO0PIN & (1<<9)) //if pin on { FIO0CLR = (1<<9); //pin off } else { FIO0SET = (1<<9);//else pin on } } } int main() { //setup diode SCS |= 1; //enable FIO PINSEL0 &=~0x000C0000; FIO0DIR |= (1<<9); FIO0SET = (1<<9); //setup timer0 PCONP |= (1 << 1); // power up timer 0 T0CTCR = 0; // timer only mode */ T0TCR = 0; // disable timer 0 PCLKSEL1 &= ~0x0000000C; PCLKSEL0 |= 0x00000004; // timer 0 clock = PCLCK T0IR = 0xFF; // reset irq flag T0PR = 0x00208D55; // prescaler T0MR0 = 5; // match register 0 // configure VIC VICIntEnClr |= (1 << 4); // irq disabling VICIntSelect &= ~(1 << 4);// IRQ interrupt //VICVectPriority4 = 2; // priority VICVectCntl4 =2; // (i use old naming convention here) VICVectAddr4 = (unsigned long)&t0_irq; // ISR address VICIntEnable |= (1 << 4); // irq enable T0MCR |= 0x03; // irq and TC reset on MR0 T0TCR = 0x01; // start timer while(1) { } }
Same happens if I use GPIO instead of FIO, or MR1/2/3 registers. Or even timer1. I also tried to use MR0 to SET gpio, MR1 to clear it (irq on MR0, irq+reset on MR1, etc.). In all cases interrupt routine seems to be entered only once.
you forgot the acknowlege the interrupt at the VIC:
VIC0->VAR = 0 ; // Acknowledge Interrupt VIC1->VAR = 0 ; // Acknowledge Interrupt
I hope this helps.
Tamir
do search for "lpc gpio vic" on goolge
ho, sorry, I am not sure the ARM7 has 2 VICs - the code snippet I posted works for an ARM9. But anyway you must also acknowledge the interrpt at your VIC.
Well, happy end.
I added next string at the end of ISR:
VICVectAddr = 0;
Somehow, it skipped out of my mind. Sorry.
Tamir, I've successfully discovered it myself, :) but thanks anyway. ;)