CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Using HIGH and FAST interrupts with PIC18F2620

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rprodrigues



Joined: 06 Mar 2008
Posts: 14

View user's profile Send private message

Using HIGH and FAST interrupts with PIC18F2620
PostPosted: Sun Nov 02, 2008 12:54 pm     Reply with quote

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.
Ttelmah
Guest







PostPosted: Sun Nov 02, 2008 2:54 pm     Reply with quote

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
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Nov 02, 2008 2:54 pm     Reply with quote

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).
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 02, 2008 2:59 pm     Reply with quote

Thank you for those explanations. Finally I understand what CCS is doing
with all those directives.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Nov 02, 2008 3:37 pm     Reply with quote

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
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 02, 2008 3:49 pm     Reply with quote

Well, I wanted to congratulate you and RJ on your clear explanations.
rprodrigues



Joined: 06 Mar 2008
Posts: 14

View user's profile Send private message

Thank you!
PostPosted: Sun Nov 02, 2008 3:57 pm     Reply with quote

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
Ttelmah
Guest







PostPosted: Mon Nov 03, 2008 5:11 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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