CCS :: View topic - multiple interrupts http://ccsinfo.com/forum/viewtopic.php?t=25400&highlight=inte...
FAQ Forum Help Official CCS Support Search Register
Profile Log in to check your private messages Log in
multiple interrupts
CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic
Author Message
eaton10500 multiple interrupts
Guest 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 Posted: Sat Dec 10, 2005 10:34 am
Guest
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) {
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
eaton 10050 Posted: Sat Dec 10, 2005 11:10 am
Guest
Thanks tt
i think that work just great
Display posts from previous: All Posts Oldest First Go
All times are GMT - 6 Hours
CCS Forum Index -> General CCS C Discussion
Page 1 of 1
Jump to: General CCS C Discussion Go
You can post new topics in this forum
You can 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
2 от 2 01.3.2007 г. 11:28