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 support@ccsinfo.com

Writng an Interupt handler

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



Joined: 27 Oct 2005
Posts: 7

View user's profile Send private message

Writng an Interupt handler
PostPosted: Tue Nov 15, 2005 9:41 am     Reply with quote

Is anyone able to tell me, simply, how I can write my own interrupt handler.
I will have 1 high priority interrupt which must over rule all others and then I will have 4 low priority interrupts.
For the low priority interrupts I must save the Status, Wreg and other things such that the code will return from the interrupt with everything set the way it was at the point of interrupt, eg BSR and PC's etc..

I'm using a 18F452

We've tried using the ISR handler that comes with the compiler v3.236 but I'm still getting problems where the low priority interrupt isn't saving the Wreg, BSR and Status. I've tried putting a post up about this before but didn't get the answer I needed. Plus due to the the problems mentioned it's been mandated to me that we must not uses any library functions.

So if someone can help with writing a bespoke ISR I'd be most greatful!
Ttelmah
Guest







PostPosted: Tue Nov 15, 2005 9:58 am     Reply with quote

There is nothing wrong with the supplied ISR code, _provided you know what you are doing_. This is even more true for going DIY...
If I remember correctly, you were mixing the use of the 'FAST' handler, with the 'HIGH' code, which will result in problems. Basically, if you use 'FAST', you prevent the compiler from being able to use this for it's own handler (which it will assume, if 'high' is selected elsewhere).
The way it works, is that there are a number of options:
1) Have some normal ISR's, and some 'HIGH' ISR's. The compiler then works fine, and will use the fast return ability for the high priority interrupts.
2) Have normal ISR's, _and only one 'FAST' ISR. If this is done, the compiler does not save the registers for the latter ISR, but does use the fast return ability, and the high priority interrupt for it. If you then manually save any other registers needed, this gives the fastest handling of a single high priority interrupt.
What you cannot do, is use both 'HIGH', and 'FAST' in one program.
I have posted global ISR handlers in the past for using the high priority interrupt,in the days before the compiler had this working, and they are in the archives. However there is no 'general' solution for this, since you will need to manually determine from the list file, which registers have to be saved...

Best Wishes
c_bellsham



Joined: 27 Oct 2005
Posts: 7

View user's profile Send private message

PostPosted: Thu Nov 17, 2005 8:06 am     Reply with quote

This is really starting to get on my wick.

I've added the line:-
#device PIC18F452 ICD=TRUE HIGH_INTS=TRUE
and I get the following error:-
Error 104 Extra Characters on the preprocessor command line.

So I removed that and tried the FAST:-
#int_LOWVOLT FAST
void LOWVOLT_isr(void)
And I get an error:-
Error 159 Invalid interrupt direcive Requires #device HIGH_INTS=TRUE
So I add that line back in and then I get both error 104 and 159

what the hell is going on with this dumb thing?
Or is it me?
ckielstra



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

View user's profile Send private message

PostPosted: Thu Nov 17, 2005 12:40 pm     Reply with quote

Quote:
I've added the line:-
#device PIC18F452 ICD=TRUE HIGH_INTS=TRUE
and I get the following error:-
Error 104 Extra Characters on the preprocessor command line.

I couldn't understand why you have problems while it's working for me.
From the readme.txt:
Quote:
you must add the following line after you include the device .h file:
#device HIGH_INTS=TRUE

The big difference is that you are not including the 18f452.h file which also happens to do a #define for TRUE..... Cool

What also works is:
Code:
#device PIC18F452 ICD=1 HIGH_INTS=1
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