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

LPC2468 timer interrupt

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

Parents
  • 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

Reply
  • 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

Children
No data