LPC2119 Timer Interrupt

Hi, i managed to make a timer but my problem arises when i try to create an interrupt once the timer finishes. The timer works good. Here is the code:

Timer Initialization

void init_timer (void) 
{
	VPBDIV		= 0x1;				//Set pclk to 19.6608 Mhz
	T0PR 		= 0;					//prescaler set to 0
	T0TCR 		= 0x2;				//Reset counter and prescaler
	T0MCR              = 0x3;				//Reset on match. Interrupt Enabled
	T0MR0              = 5000;                             //Set time
	T0TCR 		= 0x1;				//enable timer

	VICVectAddr4 = (unsigned)T0isr;		        //Set the timer ISR vector address
	VICVectCntl4 = 0x00000024;			//Set channel
	VICIntEnable |= 0x00000010;			//Enable the interrupt
}

Interrupt

void T0isr (void)	__irq
{
	IOSET0 = 0x1;						//Turn LED2 ON
	Delay();							//Delay
	IOCLR0 = 0x1;	  					//Turn LED2 OFF

	T0IR 		= 0x1;					//Clear Match 0 interrupt
	VICVectAddr = 0x00000000;			//Dummy write to signal end of interrupt
}

Main

int main (void) 
{

  IODIR0 = 0xFFFFFFFF;					//Set all pins as output
  init_timer ();						//Initialize timer

  while(1)
  {
		IOSET0 = 0x2;					//Turn LED1 ON
		IOCLR0 = 0x2;					//Turn LED1 OFF
  }
}

Thanks in advance.

One possibility is that you’re getting another timer interrupt before the Delay() completes.

Interrupt routine has a basic no-no: Don’t call delay(), and don’t call library routines.