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] how to handle multiple interrupt in PIC using Mikro C software

Status
Not open for further replies.

phrbob93

Member level 1
Joined
Mar 28, 2014
Messages
38
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Location
Jalandhar, punjab
Activity points
343
here i am programming PIC16F877a Micro controller for interrupt
i did a program of handling external Interrupt and it is working correct, for the service routine of External interrupt i was instructed to add a ISR function(can be of any name) with interrupt keyword,
for e.g. i use
void interrupt external(void) // interrupt keyword followed by any name for function
{
//ISR code.............
}

now i want to do a program in which there are multiple interrupt lets say i want to program external interrupt and timer interrupt in the same program..
for that i will use
void interrupt timer(void){
//ISR code.............
}

so my question is how compiler will distinguish between timer ISR function and external ISR function ??
 

You usually have only one isr function and you check the interrupt flags individually to see which interrupt was triggered:

void interrupt(){
//An interrupt was triggered

if(INT0IF == 1){//Check if external interrupt event occured
// place code for handling INT0 interrupt here and clear interrupt flag
}

if(T2IF == 1){//check if TMR2 caused the interrupt
// place code for handling TMR2 interrupt here and clear interrupt flag
}

//Exit ISR
}
 

so my question is how compiler will distinguish between timer ISR function and external ISR function ??

For ISR there is different interrupt vector handler for different interrupts you can check in its header file.
 

For ISR there is different interrupt vector handler for different interrupts you can check in its header file.

Correct me if I am wrong, but I don't think mikroc for pic16 has multiple handlers/identifiers for different interrupts and doesn't pic16 have only one interrupt vector? (He probably won't find isr vector defs in the device's header file)

In mikroC you can proably define multiple interrupt functions using the interrupt keyword, but you will probably have to check the interrupt flags to indentify which interrupt to service.
 

  • Like
Reactions: ernpao

    ernpao

    Points: 2
    Helpful Answer Positive Rating
Although the original question has been already properly answered, a point that deserves some attention when dealing with multiple interrupts is related to the need of routine perform the treatment efficiently, being necessary to get out of the interrupt vector as quick as possible, in order to avoid that other interrupt events goes unnoticed.
 
  • Like
Reactions: ud23

    ud23

    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