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.

what happens if 2nd interrupt occurs while the ISR of the 1st is being executed

Status
Not open for further replies.

matrixofdynamism

Advanced Member level 2
Joined
Apr 17, 2011
Messages
593
Helped
24
Reputation
48
Reaction score
23
Trophy points
1,298
Activity points
7,681
An interrupt causes a microcontroller/microprocessor to leave the normal execution flow and execute an ISR. Interrupts can have priority over other interrupts.

What happens if an interrupt occurs and its interrupt service routine is being executed and before it finishes, another interrupt occurs? Will the processor move to executing this 2nd interrupt once the current service routing reaches its end? How is this usually dealt with as I am sure such a scenario is quite common.
 

on PIC MCU
GIE bit is OFF when entering inside interrupt treatment
and will be put ON at the end of interrupt
so only interrupts with the correspondig Flag interrupt allready "ON" could be executed inside one interrupt.
so next IT treatment will occur just after return to the main..

it is the main reason to keep interrupt treatment as short as possible
and do each specifique treatment in the main.


but you can have 2 levels of interrupt ...
or more with ehanced MCU (PIC24 PIC32 ) .. with many priority levels.
 
...... Will the processor move to executing this 2nd interrupt once the current service routing reaches its end? How is this usually dealt with as I am sure such a scenario is quite common.

If an interrupt service routine is in progress , then that can be interrupted by a higher priority interrupt.
 
OK, if an ISR is in progress and a lower priority interrupt occurs, will it be ignored or will it be carried as soon as the current ISR ends?
 

OK, in that case, is it that interrupts will always have priority in every system? I mean, is this always held true?
 

OK, in that case, is it that interrupts will always have priority in every system? I mean, is this always held true?

yes. priority is always there when there are more than one interrupt request.
 
That's the reason for assigning interrupts. All the systems carry interrupts within themselves. Priority should be assigned if there is more than one interrupt.
 
Normally interrupts are not reeabled when the interrupt service routine is run, so it will finish executing, and the pending interrupt with the highest priority will then take control when interrupts is reenabled at return from interrupt.

Note that you have to reeable the interrupt system in the ISR yourself. Before you do that, you need to be very certain that your code is fast enough to serve any interrupt situation, and it has to be reentrant in way that does not use up all the stack space before it is possible to clean out all pending interrupts. Stack space is the big question here.

Priority levels are normally processed only when more than one interrupt is pending at the same time.

Some processors have special interrupts that can not be disabled(non maskable interrupt), and will always be executed. This is a special superhigh priority interrupt, and used sparingly, even if available. I've seen it used only one time, and that was an emergency interrupt with higher priority than power fail. I suppose exactly power fail could be such a high priority source, in any system.
 

Note that you have to reeable the interrupt system in the ISR yourself.

Gorgon, in the PIC family the interrupts for the current priority are automatically turned off as the ISR is enetered and re-enabled by the return ('retfie') instuction that terminates the ISR. If you enable it within the ISR it would likely cause problems.

Brian.
 

Gorgon, in the PIC family the interrupts for the current priority are automatically turned off as the ISR is enetered and re-enabled by the return ('retfie') instuction that terminates the ISR. If you enable it within the ISR it would likely cause problems.

Brian.

Yes, I suppose that is the general idea of my post too? Most processors I've used from different brands will disable the interrupt when entering the ISR, and you need to control interrupt enable yourself to get a reentrant interrupt system. That is generally a very bad idea in itself , for any processor family.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top