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

ISR Handling problem in LPC2378

Hi,

Please help

I have written a c code for LPC2378 microcontroller, inorder to set a timer0 and generate an interrupt whenever the timer overflow occurs and the interrupt is mapped to VIC timer0 vector address 4. The problem is while watching the timer and vector register values.............the overflow is happening finely, the interrupt is generated and notified to the VIC by changing the VIC vector address where the PC has to take control but the pc is not changed to that location to execute the subroutine. Please help me.

Please find my attached code.

#include <stdio.h>
#include <LPC23xx.H> /* LPC23xx definitions */
__irq void T0_IRQHandler (void);
int main (void)
{ /* Enable and setup timer interrupt, start timer */
T0MR0 = 10;
T0MCR = 3; /* Interrupt and Reset on MR0 */
T0TCR = 1; /* Timer0 Enable */
T0PR = 10; /* Timer0 Enable */
VICVectAddr4 = (unsigned long)T0_IRQHandler;/* Set Interrupt Vector */
VICVectCntl4 = 15; /* use it for Timer0 Interrupt priority is 5*/
VICIntEnable = (1 << 4); /* Enable Timer0 Interrupt */
while(1)
{ }
}

/* Import function for turning LEDs on or off */
/* Timer0 IRQ: Executed periodically */

__irq void T0_IRQHandler (void)
{ static int clk_cntr;
clk_cntr++;
if (clk_cntr >= 1000)
{ clk_cntr = 0; /* Activate flag every 1 second */
} T0IR = 1; /* Clear interrupt flag */
VICVectAddr = 0; /* Acknowledge Interrupt */
}

Parents
  • I agree - 10 is way too small. The system may be being swamped by interrupts. My LPC2378 interrupt example written in Oberon-07 works OK and in that I have set T1MR0 := 100000. The relevant code snippets (using Timer1) are:

    Initialisation:
    
      (* Timer match value *)
      SYSTEM.PUT(LPC.T1MR0, 100000);
      (* MR0 Interrupt (MR0I: {0}) and Reset (MR0R: {1}) on match *)
      SYSTEM.PUT(LPC.T1MCR, {0, 1});
    
    
    Module IRQTimer:
    
    PROCEDURE TimerHandler[4]; (* 4 for IRQ or FIQ *)
    BEGIN
      INC(timeVal);
      (* Clear the MR0 interrupt *)
      SYSTEM.PUT(LPC.T1IR, {0});
      (* Update the VIC priority hardware *)
      SYSTEM.PUT(LPC.VICVectAddr, 0)
    END TimerHandler;
    
    
    Client Module:
    
    PROCEDURE Wait();
    VAR
      i: INTEGER;
    BEGIN
      i := IRQTimer.timeVal;
      WHILE ABS(IRQTimer.timeVal - i) < 100 DO END
    END Wait;
    
    

    Chris Burrows
    CFB Software
    Armaide v2.0: LPC2xxx Oberon-07 Development System
    www.cfbsoftware.com/armaide

Reply
  • I agree - 10 is way too small. The system may be being swamped by interrupts. My LPC2378 interrupt example written in Oberon-07 works OK and in that I have set T1MR0 := 100000. The relevant code snippets (using Timer1) are:

    Initialisation:
    
      (* Timer match value *)
      SYSTEM.PUT(LPC.T1MR0, 100000);
      (* MR0 Interrupt (MR0I: {0}) and Reset (MR0R: {1}) on match *)
      SYSTEM.PUT(LPC.T1MCR, {0, 1});
    
    
    Module IRQTimer:
    
    PROCEDURE TimerHandler[4]; (* 4 for IRQ or FIQ *)
    BEGIN
      INC(timeVal);
      (* Clear the MR0 interrupt *)
      SYSTEM.PUT(LPC.T1IR, {0});
      (* Update the VIC priority hardware *)
      SYSTEM.PUT(LPC.VICVectAddr, 0)
    END TimerHandler;
    
    
    Client Module:
    
    PROCEDURE Wait();
    VAR
      i: INTEGER;
    BEGIN
      i := IRQTimer.timeVal;
      WHILE ABS(IRQTimer.timeVal - i) < 100 DO END
    END Wait;
    
    

    Chris Burrows
    CFB Software
    Armaide v2.0: LPC2xxx Oberon-07 Development System
    www.cfbsoftware.com/armaide

Children
No data