Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Multi Interrupt with PIC

Status
Not open for further replies.
You check the various flags of the perifials you have enabled for interrupt. Something like this in your ISR to branch to the appropriate handler:
Code:
BTFSC PIR1, TMR1IF ; Timer1 overflow interrupt?
GOTO T1_INT ; YES
BTFSC PIR1, ADIF ; A/D interrupt?
GOTO AD_INT ; YES, do A/D thing
; NO, do this for all other interrupt sources
 
Last edited:
Well there are differences among PICs here.
In PIC16, all interrupts are the same priority. The processor jumps to the top of your ISR routine any time it's NOT already running the interrupt code and any enabled flag is set. It's up to you to write code to figure out which flag is set and how to handle it and return.
In PIC18, you can do that but there is also 2 interrupt priorities you MAY choose to use. The processor will jump to the higher priority interrupt handler even if the low priority interrupt handler is already running. The opposite is not true.
In dsPIC, there is a different interrupt vector for each interrupt source, so you have to write a separate handler task for each source. Also there are a lot of different interrupt priority levels (0-7 IIRC) you can assign.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top