This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Timer interrupt for led blinking is not working.

Hi.. I am trying to blink an led using a timer interrupt. Connected the led to P0.0 and the code is as shown below. Is there any problem with the code??


#include<lpc21xx.h>

void __irq timer0(void);
void timersetup(void);

int main()
{
        PINSEL0 = 0x00000000;
        PINSEL1 = 0x00000000;
        IODIR0 = 0x01;
        IOSET0=0x01;
        timersetup();

        while(1);
}

void timersetup(void)
{
        VICIntSelect=0x0;
        VICVectCntl0=0x20|4;
        VICVectAddr0=(unsigned long)timer0;
        VICIntEnable=(1<<4);

        T0TCR = 0x02;  //Reset the timer0
        T0PR=0x00;     //Set prescaler to 0
        T0MR0=0x0FFF;  //Match register value
        T0IR=0x01;     //Clear match0 interrupt
        T0MCR= 0x03;   //Enable interrupt on MR0 and enable Reset on MR0
        T0TCR = 0x01;   //Start timer0
}

void __irq timer0(void)
{
        IOPIN0^=0x01;   //Toggle LED on p0.0
        VICVectAddr=0;
        T0IR=0x01;      //Reset match0 interrupt

}