We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi, I have written code that generate Interrupt on Timer-0 match.(LPC2138) But problem is that when I debuge the code in Keil Complier it does not go to ISR. I aslo use the Sample code from keil that genrate interrupt on Timer match.But that aslo give same problem. Does it need to change Start up code before you write code for Interrupt.
Below I have given code that I hvae written.
#include<LPC21xx.H>
void T0isr(void) __irq;
unsigned int x;
int main(void) { IO0DIR=0XFFFFFFFF; T0TCR=0X00000000 //TIMER0 COUNTER DISABLE T0TC=0X00000000; //TIMER0 COUNTER SET TO 0 T0PR=0X00000001; //PRESCLAR FOR TIMER0 SET TO 1 T0PC=0X00000000; //PRESCLAR COUNTER FOR TIMER0 SET 0 T0MCR=0X00000003; //MR0 SET TO RESET AND GENERATE INT T0EMR=0X00000000; //MRO SET DO NOTHING ON MATCH T0MR0=0XFFFF; //MR0 SET 0XFFFF
VICVectAddr4 = (unsigned)T0isr; //Set the timer ISR vector address
VICVectCntl4 = 0x00000024; //Set channel
VICIntEnable = 0x00000010; //Enable the TIMER-0 interrupt
T0TCR=0X00000001; //TIMER0 COUNTER ENABLE
for(;;);
}
void T0isr (void) __irq { T0TCR=0X00000000; //TIMER0 COUNTER DISABLE IO0PIN=0XFFFFFFFF; //HIGH THE OUTPUT for(x=0;x<10000;x++); // DELAY IO0PIN=0X00000000; //LOW THE OUTPUT for(x=0;x<10000;x++); // DELAY T0IR= 0x00000001; //Clear match 0 interrupt VICVectAddr = 0x00000000; //Dummy write to signal end of interrupt
T0TCR=0X00000001; //TIMER0 COUNTER ENABLE }
Yes, the simulator do support interrupts. If it didn't, it would be meaningless to use it.