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 everybody! I need some help. I 'm trying to blink a led by using Timer0 and an IRQ Routine on a LPC2129. I know my Timer work well (bit 0 in TOIR is generated about 900ms) But I don't understand why it never launch my ISR routine. I put a breakpoint and it never go there.
Maybe someone can help me to resolve it! he would be nice! Thank you.
#include <stdlib.h> #include <LPC23xx.H> #define Fpclk 12000000 char data; void TIMER1_ISR(void) __irq { //VICSoftIntClear=0xFFFFFFFF; //Clear all interrupts T0IR = 0x01; // set match 0 T0TCR=0x03; //counter reset if(IOSET1==0x10000){ IOCLR1 = 0x10000; } else if (IOCLR1==0x10000){ IOSET1 = 0x10000; } } int main( void ){ IODIR1 = 0x10000; //init VIC VICIntSelect=0x00000000; //all interupts: IRQ VICIntEnable=0xFFFFFFFF; //all interupts : enabled VICVectCntl4=0x00000014;//Uart interupt selected and enbled VICVectAddr4 = (unsigned long)TIMER1_ISR; //adress of the irq routine PCONP=0x02; //do not activate power saving T0MR0 = Fpclk - 1; // when T0TC arrived to 1 seconde (12000000 ticks) , the match between T0TC and T0MR0 do an interuption T0PR = 0x00; //1 incrementation every tick T0MCR = 0x07; //stop ,reset,interuption enabled when timer 0 match to match0 */ T0TCR = 0x01; //start counter while(1); }
Wow - just noticed something.
You say you have a LPC2129.
But why then do you use the include file #include <LPC23xx.H>?
The LPC23xx is a newer processor family that just happens to be very similar since most of the peripherials are supersets of the LPC21xx functionality for ease of migration.
Of course your program doesn't work as it should. You have just been unlucky that it seemed to _almost_ work.
Yeah, it works well!!! Thanks "Per Westermark" i'm going to make a little sheduler now!
here is my code:
#include <LPC21xx.H> #define Fpclk 12000000 void TIMER1_ISR(void) __irq { if(((IOPIN1&0x10000)>>16)==1){ IOCLR1 = 0x10000; } else if (((IOPIN1&0x10000)>>16)==0){ IOSET1 = 0x10000; } T0IR = 0x01; // set match 0 VICVectAddr = 0xff;/* Dummy write to ACK the VIC */ } int main( void ){ IODIR1 = 0x10000; //init VIC VICIntSelect=0xFFFFFFEF; //TMR0 interupt: IRQ VICIntEnable=0x00000010; //TMR0 interupt : enabled VICVectCntl4=0x00000024;//timer interupt selected and enbled VICVectAddr4 = (unsigned long)TIMER1_ISR; //adress of the irq routine PCONP=0x02; //do not activate power saving T0MR0 = Fpclk - 1; // when T0TC arrived to 1 seconde (12000000 ticks) , the match between T0TC and T0MR0 do an interuption T0PR = 0x00; //1 incrementation every tick T0MCR = 0x03; //stop ,reset,interuption enabled when timer 0 match to match0 */ T0TCR = 0x01; //start counter while(1); }