CCS - View Topic - Multiple Interrupts
CCS - View Topic - Multiple Interrupts
multiple interrupts
Author Message
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,
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
#int_timerx noclear
void timer_interrupt(void) {
1 от 2 01.3.2007 г. 11:28
CCS :: View topic - multiple interrupts http://ccsinfo.com/forum/viewtopic.php?t=25400&highlight=inte...
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
Thanks tt
i think that work just great
Page 1 of 1
2 от 2 01.3.2007 г. 11:28