|
|
View previous topic :: View next topic |
Author |
Message |
valemike Guest
|
nested interrupt |
Posted: Thu Feb 26, 2004 11:03 am |
|
|
PIC16F876; no "fast interrupt"
If i get interrupted by timer 0, and i'm running the isr (that is enclosed by the #INT_TIMER0 routine, i assume that interrupts are disabled while i'm executing.
Now what if i get a falling edge interrupt on pin RB0 while i'm running the timer isr? When will this external interrupt RB0 interrupt run? Will it run after i exit the current ISR? Or does CCS clear ALL pending interrupt flags?
Thanks,
Mike |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Thu Feb 26, 2004 11:21 am |
|
|
Interupt flags are cleared as they are serviced. The risk is getting more than one interupt prior to running the service routine. In that case the flag is already set when the second interupt trigger occures and the flag simply remains set. For a clock routine this would mean loosing time. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
Interrupts |
Posted: Thu Feb 26, 2004 11:23 am |
|
|
I am taking this info from a post by Ttelmah just yesterday (the 25th):
**************************************************
Basically, when an 'event' occurs, the interrupt flag is set. This happens whether or not the processor is inside a handler, or in the main code. When the processor exits an interrupt handler, restores the register, and returns to the main code, interrupts are re-enabled, and if the interrupt flag is set, there will be an immediate interrupt again.
If there are two basically identical interrupts, one will have priority over the other, simply on the basis that it's flag is tested first in the global handler (you can set this order with the #priority directive). When an interrupt occurs, there is a significant delay while the global handler saves lots of registers, then the tests are made. There is then a further delay to handle the actual interrupt routine, and then more delay while the registers are restored. If (for instance), two serial interrupts occur at once, the second handler, will only be reached, after the entire time associated with handling the first interrupt has taken place, and then the register saving, and test process, has been repeated for a second time.
***********************************************
This scenario basically applies to all interrupts regardles of the source.
You really do need to search the board before asking questions. It would get you the information immediately rather than having to wait on a reply and not have us repeating the info over and over. If you saw the above info you should say so and reference the info to keep the replies as brief as possible.
Regards |
|
|
valemike Guest
|
a possible workaround? |
Posted: Thu Feb 26, 2004 12:23 pm |
|
|
I'm in a place where excessive browsing is contrary to policy. But thanks for that advice about looking it up first before cluttering up the board with duplicate responses.
Getting back to the technical side...
So if i wanted to save myself the time of restoring the registers before leaving the current isr, only to have it slip into the pending isr all over again, --> Before leaving the current isr, i would check if there is a pending interrupt flag set waiting to be serviced. I can then duplicate the source code from that pending isr (or i can use some kludgy "goto" statements). Then clear that flag of the interrupt i just manually serviced (since it won't be cleared by exiting my current isr). I guess that might work. |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: a possible workaround? |
Posted: Thu Feb 26, 2004 12:39 pm |
|
|
valemike wrote: | I'm in a place where excessive browsing is contrary to policy. But thanks for that advice about looking it up first before cluttering up the board with duplicate responses.
Getting back to the technical side...
So if i wanted to save myself the time of restoring the registers before leaving the current isr, only to have it slip into the pending isr all over again, --> Before leaving the current isr, i would check if there is a pending interrupt flag set waiting to be serviced. I can then duplicate the source code from that pending isr (or i can use some kludgy "goto" statements). Then clear that flag of the interrupt i just manually serviced (since it won't be cleared by exiting my current isr). I guess that might work. |
I believe the compiler does this already. Insure there are no pending interupt flags prior to exit of the interupt handler. The interupt handler calls the individual interupt functions as required. When all interupt flags are cleared the handler will restore stack and return to main code excecution. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 26, 2004 1:17 pm |
|
|
Quote: | I believe the compiler does this already. | It actually doesn't do that. The CCS interrupt dispatcher will only
handle one interrupt at a time. When it finishes executing your isr,
it goes directly to the "restore" code in the bottom half of the dispatcher.
It has to completely exit the dispatcher before it can handle your
next pending interrupt.
With regard to handling a different interrupt while you're within
your isr, I posted some code here. It checks for a Timer1 interrupt
while it's in the CCP interrupt isr.
http://www.ccsinfo.com/forum/viewtopic.php?t=906 |
|
|
|
|
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
|