Hi, I am using GNU ARM C compiler from Raisonace(RIDE). I have written code for LPC2148 that generate interrupt when Timer-1 match the register T1MR0. ISR simply turn on LED on Port 1. Problem is that Code come out of main loop but does not go to ISR. I search a lot in the examples code and have used a lot but nothing likes to work. Do I need to make changes in Start-up code. I have attached Startup code file. #include<lpc21xx.h> #define LED1 0x00000001; #define LED2 0x00000002; void delay(void); void TIMER1_IRQ(void) _attribute_ ((interrupt("IRQ")));; int main (void) { IO0DIR =0XFFFFFFFF; IO0SET = LED2; /*********************************** TIMER-0 SETUP FORDELAY********************************/ VPBDIV = 0x02; //DIVIDED CCLOCK BY TWO T0CTCR = 0X00; //SET COUNTER AS TIMER T0MCR = 0X06; //TC REST ON MATCH T0IR = 0X00; //CLEAR ALL INTERRUPT T0PR = 0X06; //COUNTER CLOCK DIVIDED BY 6=1MHz /*********************************** TIMER-1 SETUP INTERRUPT AFTER 1SEC*******************************/ T1TCR = 0X02; //MAKE TC REST T1CTCR = 0X00; //SET COUNTER AS TIMER T1MCR = 0X03; //INTERRUPT AND REST ON MATCH T1IR = 0X00; //CLEAR ALL INTERRUPT T1PR = 0X06; //COUNTER CLOCK DIVIDED BY 6=1MHz T1MR0 = 1000000; //MATCH-0=1000 VICIntSelect = 0x00000000; //SET THE TIMER-1 MATCH-0 INTERRUPT AS IRQ VICVectCntl0 = 0x00000025; //SET CHANNEL VICVectAddr0 =(unsigned long)TIMER1_IRQ; //LOCAD THE ADDRESS OF ISR VICIntEnable = 0x00000020; //ENABLE TIMER1 INTERRUPT T1TCR =0X01; //ENABLE TIMER-1 for(;;) { IO0SET = LED1; delay(); IO0CLR = LED1; delay(); } } /**************************************** End Main**************************************************/ void delay(void) { T0MR0 = 250000; //MATCH-0=250000 T0TCR = 0X01; //TURN ON TIMER-0 while((T0TCR & 0X01)==0X01); //WAIT FOR TIMER MATCH AND INTERRUPT FLAG SET T0TCR = 0X00; //TURN OFF AND RESET TIMER-0 } /********************************** INTERRUPT SUBROUTINE**************************************/ void TIMER1_IRQ(void) { IO0CLR = LED2; T1IR |=0X00000001; //CLEAR MATCH-0 INTERRUPT VICVectAddr =0X00000000; T1TCR = 0X01; //TURN ON TIMER-0 }
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.