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.

PIC 16F877A Intrrupt

Status
Not open for further replies.

pasidu

Member level 3
Joined
Jul 16, 2016
Messages
58
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
494
Dear All
This is related to PIC 16F877a interrupt

Lets assume that the micro controller interrupted by external interrupt then its gone to interrupt vector 0x04 and global interrupt was disabled

After interrupt was fired another two flags were set Ex TMR0IF and TMR1IF still in the ISR vector

my question is

which interrupt will be fired first to the next out of TMR0IF and TMR1IF

Please advice
Thanks in advance
 

there is no interrupt priority in PIC16 and there is single interrupt vector.
when you are in ISR no interrupt will be fired because GIE is disabled
only flags are set
 

Meaning the priority is decided in your ISR depending on which flag you check first. The flags are set regardless of whether GIE is enabled or not, all GIE does is determine if the program jumps to the ISR. If you are polling the flags you can still use the interrupt system without an ISR but of course it tends to make the program less responsive.

Brian.
 
  • Like
Reactions: pasidu

    pasidu

    Points: 2
    Helpful Answer Positive Rating
You can actually process all interrupts within the ISR if you really need to.
The typical structure of the ISR is (in pseudocode):
Code:
if interruptFlag1 & interruptEnable1 then
{ ... }
if interruptFlag2 & interruptEnable2 then
{ ... }
As the single ISR will be called with ANY interrupt is triggered, it is quite possible for you to process all active interrupts within the ISR with a single pass. If you don't reset the IF flag for an interrupt (and the IE flags are also set) then the ISR will be called again which is why you must clear the IF flag when you process the interrupt.
If you need to process one interrupt before another and both IF flags are set, then you simply put the code to handle the "one that should do first" before the "other" one within the ISR.
If you are talking about how to tell if the IF flags are being set while you sare inside the ISR then the above scheme will still work. However it almost implies that some part of the ISR is taking some time to process (which would allow the other flags to be set on a regular basis) and that is generally considered a bad thing.
Susan
 
  • Like
Reactions: pasidu

    pasidu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top