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

#priority

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 26, 2013 1:27 pm     Reply with quote

If I compile a test program with only a main() and just #priority, I get
this message from a modern version of the compiler:
Quote:
*** Error 7 "PCH_Test.c" Line 13(0,1): Invalid Pre-Processor directive No interrupts listed
BLL



Joined: 11 Nov 2006
Posts: 181
Location: Birmingham, UK

View user's profile Send private message

#Priority
PostPosted: Thu Sep 26, 2013 1:48 pm     Reply with quote

Yes, I did search the forum and didn't find the answer. If I had, I wouldn't have posted the question!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Thu Sep 26, 2013 2:32 pm     Reply with quote

First, 'priority' has nothing to do with the PIC 18 chip's hardware priority.

All it does is set the order in which interrupts are 'scanned' in the global handler. It won't allow an interrupt to interrupt another.

It'll only work, with some interrupt names.

If (for instance), you have INT_RDA, and INT_EXT, then:
Code:

#PRIORITY INT_RDA,INT_EXT


will mean that INT_RDA will be checked _first_ in the global handler.

If it is not used, interrupts are checked in the order they are declared.

It won't have been enabling hardware priorities with your 2550 code.

#PRIORITY dates in CCS, from before any chips had hardware priorities.

Hardware prioritising, is done with three separate directives:

First at the top of the program (just after the processor type is defined), you need:

#DEVICE HIGH_INTS=TRUE

This enables interrupt hardware levels to be used.

Then the interrupt that you want to be 'high priority' (in hardware), needs to have it's declaration followed by 'HIGH'. So:
Code:

#INT_RDA HIGH


There is a third directive 'FAST', but this should only be used if you know exactly what you are doing. This sets up a hardware high priority interrupt, but does not save the registers for you (equivalent to #INT_GLOBAL for the normal interrupts).

Now you need to be aware that INT_EXT, is _always_ high priority, if hardware priorities are enabled. This is a hardware limitation of the PIC.

Your "Invalid Pre-Processor directive" message comes because you have not included any interrupt names in the declaration, or the names are not ones that are enabled.

Asmboy is right, that the has been answered many times before here. I know, I've typed several of these answers.

Best Wishes
ckielstra



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

View user's profile Send private message

PostPosted: Thu Sep 26, 2013 2:45 pm     Reply with quote

Update: I see Ttelmah posted an answer while I was typing mine. For extra info I'll have it here as it is.

The hint you were given is that the error message you list does not match the code as you describe it.

One golden rule on this forum is that for the best response you should always post an example program demonstrating your problem. Make the program small, about 10 lines, and complete including the #fuses line so we can copy/paste it into our compiler.
Often when creating the tiny program you will discover the problem cause yourself.

In your project I suspect a small syntax error.

Also from your description I notice that you misunderstand how to configure the interrupt priorities. Your processor has hardware support for two interrupt levels: normal and high.
The processor's #priority directive has nothing to do with these hardware priorities. #priority is used for the special case where two interrupts of the same hardware interrupt priority occur at exactly the same moment. In that special case you can define which priority is placed higher in the list of the (software based) interrupt dissector. In my opinion an (almost) useless compiler directive. Interrupts should be handled as fast as possible, meaning that never 1 interrupt can be missed. Having designed your software that way there is no need for handling this special case.

By default the compiler sets all interrupts at the 'normal' hardware level. You create a 'high' level interrupt by adding the keyword 'HIGH':
Code:
#INT_xxx       // normal interrupt level

#INT_xxx HIGH    // High interrupt level
More info in the compiler manual in the #INT_xxxx chapter.

Note 1: INT_EXT on most chips is hard wired to the High level. This will interfere with any other High level interrupt you create.

Note 2: The CCS compiler also has a FAST directive. This is similar to the GLOBAL directive on the normal interrupt level. I do not recommend to use this unless you have extreme tight timing requirements and know exactly what you are doing as you will have to write your own assembly code for saving / restoring the registers you touch. This can change with every feature you add to your program and can even change with a new compiler release.
BLL



Joined: 11 Nov 2006
Posts: 181
Location: Birmingham, UK

View user's profile Send private message

Priority
PostPosted: Fri Sep 27, 2013 2:04 am     Reply with quote

Thank you both for your replies which have made matters much clearer. I found the reason for the error message as I had used int_rda instead of just rda!
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