Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interrupt inside an interrupt

Status
Not open for further replies.

arjun a

Newbie level 1
Joined
Nov 11, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
mumbai
Activity points
1,292
im working on an 8051 controller and i've created a program with external interrupt0 enabled.
there is no other interrupt used.
i believe interrupt inputs are generally ignored inside an ISR, and they can be enabled by
enabling the interrupt again inside the ISR. i need to enable the interrupt again inside my ISR but i want the
compliler to move to main program after the re-interrupt, rather than inside the first interrupt where it normally heads to.
is there some way of accomplishing this?? please answer my question if u have time.
thank you.
 

When an interrupt is called then the main execution stops executes the interrupt and returns back to the main in the exact point it was.

It is the same when you have recursive interrupts (assuming that your mcu supports this) , the interrupt gets stopped in order to execute the new interrupt, when that it done then the rest of the first interrupt is executed and after it is done the execution returns to main.

You cant execute the second interrupt that has interrupted the first one and then suddenly jump to the main.

Alex
 
arjun a said:
i believe interrupt inputs are generally ignored inside an ISR, and they can be enabled by enabling the interrupt again inside the ISR.

As far as I remember 8051 has an advanced interrupt system compared to other 8-bit MCUs, with interrupt priorities involved. You could take advantage of 8051's interrupts in a more sophisticated way than the one you 've described.
 

this is where assembly works wonders. in assembly, if you understood how your micro controller works...REALLY WELL... AND I MEAN REALLY WELL. You can do that manually at the end of your second interrupt.
step 1: increment the stack past all pushed registers values from 1st interrupt
at this point, you can let your program run normally with the RTS (return to subroutine) which usually jumps to the address at the current stack location. or you can use a jump (i usually prefer long jumps just to be on the safe side) and jump to your main code at the value of the program counter in memory.

Never seen it done in C, unless you want to set a variable in your second interrupt, and constantly check for it in your first interrupt

hope this helps
 

the situation that you are saying is called as nested interrupt....this situation is really tricky to handel....in this kind out situation one need to make sure that the if you are in interrupt service rountine1 and that call interrupt -2 then if interrupt-2 onces call interupt-1 then this loop will continue of interrupt -1 is perodic....so one need to disable the interrupt-1 in such a case...

Good Luck
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top