|
|
View previous topic :: View next topic |
Author |
Message |
c_bellsham
Joined: 27 Oct 2005 Posts: 7
|
Writng an Interupt handler |
Posted: Tue Nov 15, 2005 9:41 am |
|
|
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
|
|
Posted: Tue Nov 15, 2005 9:58 am |
|
|
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
|
|
Posted: Thu Nov 17, 2005 8:06 am |
|
|
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
|
|
Posted: Thu Nov 17, 2005 12:40 pm |
|
|
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.....
What also works is:
Code: | #device PIC18F452 ICD=1 HIGH_INTS=1 |
|
|
|
|
|
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
|