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

Unable to hit ISR Handler

Team,

Please suggest me what is missing/wrong?
I'm unable to hit ISR even though the timer is reset and interrupt flag is set.

I'm not using real hardware but running in simulation mode only and for LPC23xx:

My startup code:
Vectors LDR PC, Reset_Addr LDR PC, Undef_Addr LDR PC, SWI_Addr LDR PC, PAbt_Addr LDR PC, DAbt_Addr NOP ; Reserved Vector
; LDR PC, IRQ_Addr LDR PC, [PC, #-0x0120]

LDR PC, FIQ_Addr

void InitTimer1() {

/* Timer1 and Preset disabled */ T1TCR = 0x00; /* Timer Counter register, after PR is reset, this inc by 1 */ T1TC = 0x00; /* Prescalar register! Max value for prescalar counter */ T1PR = 0xFFFF; /* Prescale Counter register */ T1PC = 0x0; /* End user has to fill in the match value */ T1MR0 = 0x222; /* Reset TC and interrupt on match */ T1MCR = 0x03; /* 0000 0000 0000 0011 */
}

void InitVIC() {

VICIntSelect &= (~(1 << 5)); /* Timer 1 selected as IRQ */ /* Address of the ISR */
VICVectAddr5 = (unsigned long )Timer1_IRQ_Handler;

VICVectCntl5 = 0x20 | 5;
VICIntEnable |= (1 << 5);/* Timer 1: (bit 5) interrupt enabled */

}

void Timer1_IRQ_Handler (void) __irq
{ unsigned static int i = 0; T0IR = 0x01; /* Clear Timer1 MR0 interrupt */ IOSET0 = ~ (1 << (i+1)); if ( i == 32) i = 1; i++; VICVectAddr = 0x00;/* Dummy write to ACK the VIC */

}

int main() { InitPLL(); EnableMAM(); SetPeripheralClock(); InitGPIO(); InitTimer1(); InitVIC();

/* Timer1 and Preset Enabled */ T1TCR = 0x01;

/* Rest of the code */ while (1);

}

Parents
  • Please find code post again from editor.

    T0IR = 0x01;    /* Clear Timer1 MR0 interrupt */
    

    It was my mistake, I should have cleared T1IR instead of T0IR, though the comment is clearly referring to T1IR.

    Thanks for catching this bug.

    I've coded based on the manual but no luck so far. I'm not relying 100% on the forum responses but seeking inputs for techies.

    #include <LPC23xx.H>     /* LPC23xx definitions */
    void Timer1_IRQ_Handler(void) __irq;
    void InitVIC() {
    
            /* No PIN BLOCK HERE as we're using timer interrupt and no external interrupt */
    
            VICIntSelect &= ~(1L<<5);     /* Timer 1 selected as IRQ */
            /* Address of the ISR */
            VICVectAddr5 = (unsigned long )Timer1_IRQ_Handler;
    
            VICVectPriority5 = 0x05;
    
            VICIntEnable |= 0x20;   /* Timer 1: (bit 5) interrupt enabled */
    
    }
    
    /* Timer 1 IRQ
    
            T0IR: 4bits for MRn and 4bit for CRn
            0 - MR0 int
            1 - MR1 int
    
            3 - MR3 int
            4 - CR0 int
            5 - CR1 int
    
            7 - CR3 int
    */
    __irq void Timer1_IRQ_Handler (void)
    {
            unsigned static int i = 0;
    
            T1IR = 0x01;    /* Clear Timer1 MR0 interrupt */
    
    
            IOSET0 = ~ (1 << (i+1));
            if ( i == 32)
                    i = 1;
            i++;
    
            VICVectAddr = 0xFF;      /* Dummy write to ACK the VIC */
    
    }
    void InitTimer1() {
    
            /* Timer1 and Preset disabled */
            T1TCR = 0x00;
            /* Timer Counter register, after PR is reset, this inc by 1 */
            T1TC = 0x00;
            /* Prescalar register! Max value for prescalar counter */
            T1PR = 0xFFFF;
            /* Prescale Counter register */
            T1PC = 0x0;
            /* End user has to fill in the match value */
            T1MR0 = 0x222;
            /* Reset TC and interrupt on match */
            T1MCR = 0x03;             /* 0000 0000 0000 0011 */
    }
    int main() {
            InitPLL();
            EnableMAM();
            SetPeripheralClock();
            InitGPIO();
            InitTimer1();
            InitVIC();
    
            /* Timer1 and Preset Enabled */
            T1TCR = 0x01;
    
            /* Rest of the code */
            while (1);
    
    }
    
    

    Regards,

Reply
  • Please find code post again from editor.

    T0IR = 0x01;    /* Clear Timer1 MR0 interrupt */
    

    It was my mistake, I should have cleared T1IR instead of T0IR, though the comment is clearly referring to T1IR.

    Thanks for catching this bug.

    I've coded based on the manual but no luck so far. I'm not relying 100% on the forum responses but seeking inputs for techies.

    #include <LPC23xx.H>     /* LPC23xx definitions */
    void Timer1_IRQ_Handler(void) __irq;
    void InitVIC() {
    
            /* No PIN BLOCK HERE as we're using timer interrupt and no external interrupt */
    
            VICIntSelect &= ~(1L<<5);     /* Timer 1 selected as IRQ */
            /* Address of the ISR */
            VICVectAddr5 = (unsigned long )Timer1_IRQ_Handler;
    
            VICVectPriority5 = 0x05;
    
            VICIntEnable |= 0x20;   /* Timer 1: (bit 5) interrupt enabled */
    
    }
    
    /* Timer 1 IRQ
    
            T0IR: 4bits for MRn and 4bit for CRn
            0 - MR0 int
            1 - MR1 int
    
            3 - MR3 int
            4 - CR0 int
            5 - CR1 int
    
            7 - CR3 int
    */
    __irq void Timer1_IRQ_Handler (void)
    {
            unsigned static int i = 0;
    
            T1IR = 0x01;    /* Clear Timer1 MR0 interrupt */
    
    
            IOSET0 = ~ (1 << (i+1));
            if ( i == 32)
                    i = 1;
            i++;
    
            VICVectAddr = 0xFF;      /* Dummy write to ACK the VIC */
    
    }
    void InitTimer1() {
    
            /* Timer1 and Preset disabled */
            T1TCR = 0x00;
            /* Timer Counter register, after PR is reset, this inc by 1 */
            T1TC = 0x00;
            /* Prescalar register! Max value for prescalar counter */
            T1PR = 0xFFFF;
            /* Prescale Counter register */
            T1PC = 0x0;
            /* End user has to fill in the match value */
            T1MR0 = 0x222;
            /* Reset TC and interrupt on match */
            T1MCR = 0x03;             /* 0000 0000 0000 0011 */
    }
    int main() {
            InitPLL();
            EnableMAM();
            SetPeripheralClock();
            InitGPIO();
            InitTimer1();
            InitVIC();
    
            /* Timer1 and Preset Enabled */
            T1TCR = 0x01;
    
            /* Rest of the code */
            while (1);
    
    }
    
    

    Regards,

Children