View previous topic :: View next topic |
Author |
Message |
rprodrigues
Joined: 06 Mar 2008 Posts: 14
|
Using HIGH and FAST interrupts with PIC18F2620 |
Posted: Sun Nov 02, 2008 12:54 pm |
|
|
Hello all,
I'm trying to use HIGH and FAST interrupts in PIC18F2620 so I can get one FAST interrupt for ext1 and one HIGH interrupt for timer0, but when I use
Code: | #int_ext1 FAST
void ISR_EXT1(void)
{
// ISR CODE
}
#int_timer0 HIGH
void ISR_TIMER0(void)
{
// ISR CODE
} |
The code allocation produced by the compiler for both interrupts is the same and the one for treating HIGH interrupts.
There is also a "Warning 225" telling me that "Interrupt level changed EXT1: FAST=>HIGH".
Is there any workaround for this compiler behavior?
Thank you. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Nov 02, 2008 2:54 pm |
|
|
You can't have both.
'High', says to flag this interupt as a high priority interrupt, and add a full handler to allow multiple interrupts to be used.
'Fast', is equivalent to the 'INT_GLOBAL' instruction, and flags this as the routine to handle _all_ high priority interrupts. _No code is added by the compiler to save any registers_. You have to do this yourself.
Beware also, that on most (all?) chips, if any interrupt is flagged as high priority, INT_EXT will always become high priority as well. If this is used, a handler _must_ be added for this.
The compiler is realising this, and correctly adding the full handler.
Remember there is only one high priority interrupt vector, both 'HIGH', and 'FAST' put their code in the same place...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Nov 02, 2008 2:54 pm |
|
|
You can not combine HIGH and FAST, that's why you get the warning message.
From a hardware point of perspective there are only two interrupt levels in the PIC18: normal and high.
The CCS compiler differentiates the interrupts in three variants:
1) The normal interrupts (without keyword), including an interrupt dispatcher.
2) A HIGH interrupt which is the high level interrupt + interrupt dispatcher.
3) A FAST interrupt which is the high level interrupt without interrupt dispatcher, this saves overhead but you have to take care of saving / restoring all modified registers.
So if you want to define two high level interrupts this is only possible with the HIGH keyword. Or use the FAST keyword and write your own optimised interrupt dispatcher (not recommended as it is easy to make mistakes). |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 02, 2008 2:59 pm |
|
|
Thank you for those explanations. Finally I understand what CCS is doing
with all those directives. |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Nov 02, 2008 3:37 pm |
|
|
PCM programmer wrote: | Thank you for those explanations. Finally I understand what CCS is doing
with all those directives. | Somehow I think you already knew. ![Wink](images/smiles/icon_wink.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 02, 2008 3:49 pm |
|
|
Well, I wanted to congratulate you and RJ on your clear explanations. |
|
![](templates/subSilver/images/spacer.gif) |
rprodrigues
Joined: 06 Mar 2008 Posts: 14
|
Thank you! |
Posted: Sun Nov 02, 2008 3:57 pm |
|
|
Ttelmah, ckielstra and PCM programmer,
thank you very much for the excelent explantion given!
Now I do know what is going on and how to handle it.
Thank you |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Nov 03, 2008 5:11 am |
|
|
The 'annoying' thing really, is why they had to add a new syntax at all. To me, it would have made a lot more 'sense', to just have the 'HIGH' keyword, and as with the low priority interrupts, allow any of the interrupt names to be used, with this, or 'INT_GLOBAL'. All of the former, would behave just as for low priority interrupts, adding the handler, while the latter would define the 'global' routine for the high priority interrupts. I think it would have been easier to understand (possibly...).
As it stands, there is also a 'hole' in the ability to define things, with no 'off the shelf' instruction present, to set the high priority flag on multiple interrupts, when using the 'FAST' (INT_GLOBAL) approach. It is easy to do with a #bit definition, but it would have been 'nice' to have something like:
enable_interrupts(INT_RDA,HIGH);
Enabling the high priority bit....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|