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

Interrput Handling with LPC2378

Hi,

We are using LPC2378 controller for our application.

we written the ISR for power fail, when ever the voltage reduces the below certain voltage, it generates the IRQ, and interrupt handler completing it's functionality.

Upto now it is OK.

after completing the ISR, And the power still is available to the contoller than it is not going to main loop.

after serving the IRQ it has go back to the main routuine,can anbody inform me what might be the problem?

Regards,
P.Mahesh

Parents
  • "But i am getting one odd spike and Interrupt is generated"

    "Would be sensible to question/check the hardware"

    Yes they will check and correct it.

    "then the interrupt code itself should be examined........."

    Here is the code which i am using for initialization of EINT3 for Raising edge

    void Spoi_InitPowerFail()
    {

    /* To Enable FIQ on P2.8 */ VICIntSelect |= 0x00000100;

    /* Disable all interrupts */ VICIntEnable = 0x00000000;

    /* Set EINT3 to edge sensitive */ EXTMODE = 8;

    /* Set EINT3 to Falling-edge sensitive */
    // EXTPOLAR = 0;

    /* Set EINT3 to Raising-edge sensitive */ EXTPOLAR = 8;

    /* Need to clear this bit acording to the manual */ EXTINT = 8;

    /* Enable Falling edge interrupt on Port2.8 */
    // IO2IntEnF |= 0x100;

    /* Enable Raising edge interrupt on Port2.8 */ IO2IntEnR |= 0x100;

    /* Highest Priority (0) For Powerfail IRQ Interrupt */ VICVectCntl17 = 0x00000001;

    /* set interrupt vector */ VICVectAddr17 = (unsigned long)Spoi_PowerFailISR;

    /* Enable Interrupt */ VICIntEnable = (1 << 17);

    }

    and the isr is as follows

    void Spoi_PowerFailISR(void)__irq
    { printf("In ISR\n");

    //if (IO2IntStatR & 0x100) { //guc_PowerfailFlag = 1; /* Checking for File open */ if(EventWriteFp != NULL) { fclose(EventWriteFp); printf("A\n"); }

    if(FailureWriteFp != NULL) { fclose(FailureWriteFp); printf("B\n"); }

    printf("C\n"); }

    /* Clear Interrupt */ IO2IntClr = 0x100; VICVectAddr = ZERO; /* Acknowledge Interrupt */
    }

Reply
  • "But i am getting one odd spike and Interrupt is generated"

    "Would be sensible to question/check the hardware"

    Yes they will check and correct it.

    "then the interrupt code itself should be examined........."

    Here is the code which i am using for initialization of EINT3 for Raising edge

    void Spoi_InitPowerFail()
    {

    /* To Enable FIQ on P2.8 */ VICIntSelect |= 0x00000100;

    /* Disable all interrupts */ VICIntEnable = 0x00000000;

    /* Set EINT3 to edge sensitive */ EXTMODE = 8;

    /* Set EINT3 to Falling-edge sensitive */
    // EXTPOLAR = 0;

    /* Set EINT3 to Raising-edge sensitive */ EXTPOLAR = 8;

    /* Need to clear this bit acording to the manual */ EXTINT = 8;

    /* Enable Falling edge interrupt on Port2.8 */
    // IO2IntEnF |= 0x100;

    /* Enable Raising edge interrupt on Port2.8 */ IO2IntEnR |= 0x100;

    /* Highest Priority (0) For Powerfail IRQ Interrupt */ VICVectCntl17 = 0x00000001;

    /* set interrupt vector */ VICVectAddr17 = (unsigned long)Spoi_PowerFailISR;

    /* Enable Interrupt */ VICIntEnable = (1 << 17);

    }

    and the isr is as follows

    void Spoi_PowerFailISR(void)__irq
    { printf("In ISR\n");

    //if (IO2IntStatR & 0x100) { //guc_PowerfailFlag = 1; /* Checking for File open */ if(EventWriteFp != NULL) { fclose(EventWriteFp); printf("A\n"); }

    if(FailureWriteFp != NULL) { fclose(FailureWriteFp); printf("B\n"); }

    printf("C\n"); }

    /* Clear Interrupt */ IO2IntClr = 0x100; VICVectAddr = ZERO; /* Acknowledge Interrupt */
    }

Children
  • Difficult to read your code due to the lack of tags.

    Using file access functions in an ISR is rarely a good idea.

  • Here is the code which i am using for initialization of EINT3 for Raising edge,P2.8 is used for IRQ*/

    void Spoi_InitPowerFail()
    {

    /* To Enable FIQ on P2.8 */
    VICIntSelect |= 0x00000100;

    /* Disable all interrupts */
    VICIntEnable = 0x00000000;

    /* Set EINT3 to edge sensitive */ EXTMODE = 8;

    /* Set EINT3 to Raising-edge sensitive */
    EXTPOLAR = 8;

    /* Need to clear this bit acording to the manual */ EXTINT = 8;

    /* Enable Raising edge interrupt on Port2.8 */
    IO2IntEnR |= 0x100;

    /* Highest Priority (1) For Powerfail IRQ Interrupt */
    VICVectCntl17 = 0x00000001;

    /* set interrupt vector */
    VICVectAddr17 = (unsigned long)Spoi_PowerFailISR;

    /* Enable Interrupt */
    VICIntEnable = (1 << 17);

    }

    and the isr is as follows
    void Spoi_PowerFailISR(void)__irq
    {

    printf("In ISR\n");

    /* Clear Interrupt */ IO2IntClr = 0x100; VICVectAddr = ZERO; /* Acknowledge Interrupt */
    }

    i removed the file closing operations in ISR, then also the same problem is occured.

    I explianed the code with comments.

    Regards,
    P.Mahesh

  • Still difficult to read your code due to the lack of tags.

    Using printf in an ISR is rarely a good idea.

    Try doing something simple in the ISR, like toggle a port pin.