View previous topic :: View next topic |
Author |
Message |
sigmaorion
Joined: 22 Apr 2011 Posts: 2
|
High Priority PIC18 Interrupts |
Posted: Fri Apr 22, 2011 1:00 pm |
|
|
Hi all,
My code is something like I describe below:
----------------------------------
----------------------------------
----------------------------------
#include <18F4550.h>
#device high_ints = true
#FUSES ...
.....
.....
#FUSES ...
#use delay(clock=48000000)
#use rtos(timer=0,minor_cycle=20ms)
#INT_TIMER1 HIGH //<-- error line here
void sampletimer_int() {
...........................
interrupt code here
...........................
}
void main() {
...........................
main program here
...........................
}
----------------------------------
----------------------------------
----------------------------------
When I try to compile it I get "Error 7 "test.c" Line 19(12,17): Invalid Pre-Processor directive.
The indicated line is "#INT_TIMER1 HIGH" and the errors disappears if I delete the "HIGH" directive. I really need this interrupt to be of high priority.
Is there anything I'm doing wrong? The compiler version I use is 4.104.
Thanks in advance.
Regards... _________________ ... sigmaorion ... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Apr 22, 2011 1:41 pm |
|
|
Try this program. It compiles OK for me with vs. 4.104. It doesn't give
any errors.
Code: | #include <18F4550.h>
#device high_ints = true
#fuses HS,NOWDT,BROWNOUT,PUT,NOLVP
#use delay(clock=20M)
#int_timer1 HIGH
void t1isr(void)
{
int8 temp;
temp = 0x55;
}
//======================================
void main(void)
{
while(1);
} |
Also, try it like this. Sometimes CCS doesn't parse compiler directives.
They are treated like a "glyph". They can't accept spaces. Try it as
shown below:
Code: | #device HIGH_INTS=true |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Fri Apr 22, 2011 2:22 pm |
|
|
Separately, if you are also using the INT_EXT interrupt, you should be aware that this will always be a high priority interrupt, if high priority interrupts are enabled. Can catch the unwary.
I'm sure it's the spaces causing the problem.
Best Wishes |
|
|
sigmaorion
Joined: 22 Apr 2011 Posts: 2
|
|
Posted: Fri Apr 22, 2011 3:08 pm |
|
|
Hi guys, thank you very much for your responses.
Finally I found the problem was I had defined "define HIGH TRUE" because I wanted to use the keyword "HIGH" for pin states. Of course it was causing troubles later in the code when I tried to use the keyword HIGH to define the interrupt as high priority.
The "stupid" code:
#define HIGH TRUE
#INT_TIMER1 HIGH
Is not a good idea!!! I passed my eyes over that mistake without seeing it, hehe.
Thanks again everyone! _________________ ... sigmaorion ... |
|
|
|