• 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.

queries regarding interrupts programming....

Status
Not open for further replies.

foosm

New Member
hi all, this is my 1st time using a PIC and i am using a PIC16F877. i have a few queries regarding interrupt programming... pls help...

Lets say i am using Timer1 in Timer mode and the CCP module in capture mode, and i enabled BOTH interrupts for 'timer overflow flag' and the 'capture occured flag' .

if any one of the two events occurs, the program counter will point to the interrupt routine.... but how would i know which event is activating the interrupt ??? do i have to do a polling on the interrupt flags in the beginning of the interrupt routine to determine which event is activating the interrupt ??

or is it possible to have TWO interrupt routines ??


thanks a lot
 

motion

New Member
To use the two interrupt sources, you have to enable the TMR1IE and CCP1IE bits in the PIE1 register. During interrupt service, you have to check the TMR1IF and CCP1IF bits in the PIR1 register determine the source of the interrupt . You then also have to clear the respective bits in the PIR1 register before RETFIE. There is no automatic interrupt vectoring like those found in X86 processors.

The newer PIC18F442/PIC18F452 will allow you to have two completely separate interrupt routines by assigning one interrupt source to a higher interrupt priority over the other.
 

TheAnimus

New Member
when you think about it its the only way u could do this, how else would you assign interupt priority, just remeber to check ALL the interupt flags, its possible for 2 differn't interupts to flag within the same instruction cycle. (before GPIF is set)
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top