Hi guys
I am going through a very strange problem, I made a code which comes in timer interrupt after certain period of time but even after correct configuration of all registers the code is not coming in ISR even in the simulator. But in simulator it is observed that the interrupt flag is setting. Follwoing is the sorce code
__irq void T2_IRQHandler (void) //x milli second timer { T2IR = 1; // Clear interrupt flag VICVectAddr = 0; // Acknowledge Interrupt } /***************************************************************************************/ void inittimer() { PCONP |=(1<<22); T2MR0 = 14999; T2MCR = 3; // Interrupt and Reset on MR0 T2PR = 9; //prescale register for 10 millisec VICVectAddr26 = (unsigned long)T2_IRQHandler;// Set Interrupt Vector VICVectCntl26 = 14; // use it for Timer0 Interrupt VICIntEnable = (1 << 26); // Enable Timer0 Interrupt T2TCR = 1; // Timer0 Enable }
Please help me out
Thanx in advance
Timer 2 is not powered by default. Maybe the timer is not running...?
Hi
Thanx for the reply
I have powered up the timer by setting PCONP and yet i am able to see that the timer is running in simulator
This code works fine in simulation so I wonder what you are doing wrong.
#include <lpc24xx.h> __irq void T2_IRQHandler (void) //x milli second timer { T2IR = 1; // Clear interrupt flag VICVectAddr = 0; // Acknowledge Interrupt } /***************************************************************************************/ void inittimer() { PCONP |=(1<<22); T2MR0 = 14999; T2MCR = 3; // Interrupt and Reset on MR0 T2PR = 9; //prescale register for 10 millisec VICVectAddr26 = (unsigned long)T2_IRQHandler;// Set Interrupt Vector VICVectPriority26 = 14; // set priority to 14 VICIntEnable = (1 << 26); // Enable Timer0 Interrupt T2TCR = 1; // Timer0 Enable } void main(void){ inittimer(); while(1); }
Note the VICVectCntl does not exist in 23xx/24xx devices (check the user manual)so I would suggest you start using the existing register which is VICVectPriority which is the interrupt priority, default priority is 15 (lowest) to 0 (highest). The header file is wrong to have the VICVectCntl register (which actually points to the VICVectPriority address) since this register was used differently
Alex