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.

more than 2 interrupts in pic18f

Status
Not open for further replies.

mayyur

Newbie level 3
Newbie level 3
Joined
Mar 31, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
chico
Activity points
1,305
In pic there to levels of interrupt that is high priority(0x18) and low priority(0x08)..then if there 2 or more interrupt in these level then how will pic execute it..........i mean if the adc interrupt and timer interrupt and a external interrupt all are at one level suppose at high priority than how will pic handle this interrupt or are we manully suppose to handle this interrupt through the software.......?


thannx for the reply....
 

The response of the PIC depends on your software. Normally, when an interrupt is serviced, the global interrupt enable bit (or the high or low interrupt enable bits) becomes 0, so it prevents the other interrupts of the same level. But individual interrupt flags remain 1 if corresponding interrupts occur.

PIC simply jumps to the interrupt address. It's your job to poll the interrupt flags and take actions accordingly. Normally, when your job is done with an interrupt, you reset (make it 0) the corresponding flag bit, then return from the interrupt with RETFIE command. This also sets the global interrupt enable bit, which was reset by the hardware to prevent recurrent interrupts. Then, if there was another interrupt event while you were serving the first one, then as you didn't reset its flag in your last interrupt service, the program jumps back to the interrupt address again.

So, the sequence of interrupt services depends on both their arrival time and your polling order (assuming same priority interrupts).
 
  • Like
Reactions: sherazi

    mayyur

    Points: 2
    Helpful Answer Positive Rating

    sherazi

    Points: 2
    Helpful Answer Positive Rating
thanx for making the interrupt picture clear..........it means that while writing code i will have to use the same vector address for same prioity level i.e for two lower priority interrupt subroutine i m suppose to give the same vector address i.e 0x08 in my case for timer and adc routines.
 

Mayyur, in the PIC18, you have two vectors pre-defined. The high priority at 0x08 and low priority at 0x18. You can take advantage of that and assign some of the interrupts as high priority and some as low priority.

If you don't want to use that, you can always just 'poll' for the interrupt flag. So, for example, when an interrupt occurs, you check if the TMR0IF bit is set. If it is, the Timer 0 interrupt occurred. If not, check for whatever other sources may be (INT0, ADC, EEWRITE....etc..).
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top