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 ??
I can't help you with Mikro C, but in assembler and XC8 you simply check what caused the interrupt and act accordingly - presumably Mikro C allows the same?.
I can't help you with Mikro C, but in assembler and XC8 you simply check what caused the interrupt and act accordingly - presumably Mikro C allows the same?.
In the pic you have several registers..... PIR and PIE to name two..
One is Peripheral Interrupt Request and the other Peripheral Interrupt Enable..
If an interrupt is enabled then the interrupt flag is set and vector 0x04 is called.... When you create an interrupt function in C.. The compiler places the address of the function for you... You can then look at each flag to see which has fired the interrupt..
So if you set the timer 1 interrupt..
TMR1IE_bit = 1; and clear the Flag TMR1IF_bit = 0;
Turn on the timer .. TMR1ON_bit = 1;
Then the interrupt code will be executed when the timer spill over
In your interrupt routine do this..