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
If it's a power fail interrupt, why return?
Just stay in the interrupt in a tight loop until power finally goes.
which is also the safest thing to do, considering the deteriorating operating voltage.
Yes i agree, that is the safest, But i am getting one odd spike and Interrupt is generated.Then my application got stuck up there only.
And one more doubt is,wheter it safest or not is a different issue, why control is not transfeered main after ISR execution
"But i am getting one odd spike and Interrupt is generated"
Would be sensible to question/check the hardware.
"... why control is not transfeered main after ISR execution"
Like any (normal) interrupt, control should return to the previous execution path. Why should an interrupt triggered from a power fail be any different.
If you trigger the interrupt by something else, does execution return? If not, then the interrupt code itself should be examined.
"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 */ }
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*/
/* Highest Priority (1) For Powerfail IRQ Interrupt */ VICVectCntl17 = 0x00000001;
and the isr is as follows void Spoi_PowerFailISR(void)__irq {
printf("In ISR\n");
i removed the file closing operations in ISR, then also the same problem is occured.
I explianed the code with comments.
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.