|
|
View previous topic :: View next topic |
Author |
Message |
eaton10500 Guest
|
multiple interrupts |
Posted: Sat Dec 10, 2005 8:10 am |
|
|
Hello
I have 3 interrupts active. external,rb int on change, and a timer. The external interrupt ISR is kind of lengthy. It has to be. The question is while control is in the external int ISR there is a possibility that both the timer overflow flag and the interrupt on change flag could be set. When the external int ISR exits and the global interrupt is enabled what happens?
Which interrupt is triggered? Would it be better to ensure those flags are clear before exiting the external interrupt ISR?
Thanks, |
|
|
Ttelmah Guest
|
|
Posted: Sat Dec 10, 2005 10:34 am |
|
|
The global 'parser', bases the order that interrupts are tested for, on the order they are declared in your code, or on the order in a #priority statement if this is present.
So when the external interrupt exits, the code will go to whichever o the other interrupt handlers was defined first (unless #priority has overridden this).
You could potentially speed this with some careful programming.
Something like:
Code: |
void rbsub(void) {
//Read port B, before clearing the interrupt
clear_interrupt(INT_RB);
//rest of your RB interrupt handler here
}
#int_rb noclear
void rbint(void) {
rbsub();
}
void timersub(void)
{
clear_interrupt(INT_TIMERX);
//Need to set the interrupt used to your timer
//Rest of your timer interrupt handler here
}
#int_timerx noclear
void timer_interrupt(void) {
timersub();
}
#INT_EXT
void external_interrupt(void) {
//Have your EXT handler here
//You need to define bits to directly access the interrupt flags
//Now check for the other interrupts order these tests
//according to your own 'priority' criteria.
if (TIMERX_INTFLAG) timersub();
if (RB_CHANGED_INTFLAG) rbsub();
}
|
Now the 'handler' for the two other interrupt events, are rewritten as subroutines, and take over the function of clearing the interrut flag inside the routines. You turn off the default behaviour in the standard handler of clearing this flag.
This then allows these routines to be called inside the other interrupt handler as well. The big 'plus', is that if one of these occurs inside the long external handler, the system does not have to restore all the main registers, then see the new interrupt, and save the registers again before calling it's handler. There is a couple of extra instructions 'overhead' in the default interrupt path, to call the seperate routine.
Best Wishes |
|
|
eaton 10050 Guest
|
|
Posted: Sat Dec 10, 2005 11:10 am |
|
|
Thanks tt
i think that work just great |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|