View previous topic :: View next topic |
Author |
Message |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
Same interrupt different ISR |
Posted: Wed Nov 28, 2012 8:00 am |
|
|
Hi,
Is it possible to have different ISRs for the same interrupt?
I would like to use for example: an ISR for TMR0 while executing one function, and a Different ISR for TMR0 in another function.
Timing is "critical" so I'd like to avoid using conditional statements inside the ISR.
I'm using _TMR0 + Int on Change_ as a crude Capture/Compare.
Oone function captures, the other compares, thus the need for different ISRs.
Is it possible?
Thanks
G _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Wed Nov 28, 2012 8:30 am |
|
|
No.
However the time cost of a single bit flag and jump, is just two instruction times. Compared to the overhead of calling an ISR (typically 60+ instructions to enter and exit), this is insignificant.
Code: |
int1 use_standard_handler=TRUE;
#INT_TIMER0
void timer0_tick(void) {
if (use_standard_handler) {
//standard code
}
else {
//other code
}
}
|
It is a single bit test instruction and jump.
The jumps to the handler code, are done from ROM. You could use a RAM based table by re-writing INT_GLOBAL, but this will be significantly _slower_ than using the simple bit test. It takes something over a dozen instructions to load a jump address from an array, and then jump to it....
Best Wishes |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Wed Nov 28, 2012 10:00 am |
|
|
Thank you! _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
|