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

Problem with HIGH Interrupts

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



Joined: 01 Oct 2008
Posts: 2

View user's profile Send private message

Problem with HIGH Interrupts
PostPosted: Thu Oct 02, 2008 2:09 am     Reply with quote

My code was working fine till I place next lines for HIGH interrupt on EXT1.

Previously my code starts like that:

Quote:
#include <18F8722.h>
#device adc=10
#device *=16

#rom int8 0xf003F8={0x01}
........


And everything was o.k. But when I place the lines below:


Quote:
#include <18F8722.h>
#device adc=10
#device *=16
#device HIGH_INTS=true
#int_EXT1 HIGH


#rom int8 0xf003F8={0x01}


the compiler gives me the next errors:

Quote:

*** Error 81 "C:\...\device.h" Line 19(6,7): Expecting a basic type
*** Error 43 "C:\...\device.h" Line 19(11,19): Expecting a declaration
*** Error 43 "C:\...\device.h" Line 19(19,20): Expecting a declaration
*** Error 43 "C:\...\device.h" Line 19(20,21): Expecting a declaration
*** Error 43 "C:\...\device.h" Line 19(21,25): Expecting a declaration
*** Error 43 "C:\...\device.h" Line 19(25,26): Expecting a declaration


Line 19 is:
Quote:
#rom int8 0xf003F8={0x01}


Can someone tell me what happens? Thanks in advance!
Ttelmah
Guest







PostPosted: Thu Oct 02, 2008 2:32 am     Reply with quote

You need to place the interrupt handler routine, immediately after the line declaring the interrupt. The next 'instruction block', becomes the interrupt handler. Your next instruction block, is the #rom statement, not a function, hence won't work...

So:
Code:

#include <18F8722.h>
#device adc=10
#device *=16
#device HIGH_INTS=true

#rom int8 0xf003F8={0x01}

#INT_EXT1 HIGH
void handler_for_ext1(void) {
    //Code here for the interrupt handler

}


Best Wishes
n-squared



Joined: 03 Oct 2006
Posts: 99

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Oct 02, 2008 2:32 am     Reply with quote

Hi
You need to put the #int_EXT1 HIGH line just above the interrupt function itself.
Your sample code does not show enough detail to see the problem.

BR
_________________
Every solution has a problem.
Guest








PostPosted: Thu Oct 02, 2008 3:08 am     Reply with quote

Thanks to Ttelmah and n-squared. Thank you very much! I
Quote:
put the #int_EXT1 HIGH line just above the interrupt function itself
and now everything is o.k.

Quote:

#include <18F8722.h>
#device adc=10
#device *=16
#device HIGH_INTS=true

#rom int8 0xf003F8={0x01}

.....

#int_EXT1 HIGH
void read_isr()
{
......
}

.....


Thanks!
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Thu Oct 02, 2008 3:10 am     Reply with quote

it should be also noted that if you define
Code:
#device HIGH_INTS=true

and you dont specify any interrupt to be "HIGH" (e.g.)
Code:
#INT_EXT1 HIGH
, the PIC might behave weird.

That is what I found out. I posted that issue at this forum few months ago.
M.
csanders



Joined: 23 Apr 2005
Posts: 16

View user's profile Send private message

PostPosted: Tue Oct 14, 2008 4:18 pm     Reply with quote

Is it possible to have more than 1 ISR marked as 'HIGH'?
Ttelmah
Guest







PostPosted: Wed Oct 15, 2008 2:35 am     Reply with quote

Yes.

The behaviour of the system is fairly complex, but 'here goes'. There are two words that trigger moving the interrupt to the high priority vector, 'HIGH', and 'FAST'. When 'HIGH' is used, the compiler creates exactly the same code, as is used for the low priority handler. It automatically adds data saving code, tests for multiple interrupts if used, and jumps to the right handler. In fact on most chips this will _always_ happen, if you select as a 'HIGH' interrupt any interrupt other than INT_EXT, and then use INT_EXT as well, without adding the flag. If you look at the data sheet, there is no interrupt priority bit for INT_EXT, and if priorities are enabled, this interrupt always becomes a high priority source. This is very much a 'caveat' of the PIC. The compiler will handle this, automatically adding the test for this interrupt to the high priority code, even though it is not flagged as 'HIGH' by you.

If you instead use 'FAST', the compiler flags the selected interrupt as a high priority one, but does not add any data saving code, or tests for other interrupts. You can in fact use this as an alternative for 'INT_GLOBAL', with high priority interrupts. What you do, is flag one interrupt as 'FAST', and have it's handler save the minimum number of registers, then if necessary test for any other interrupts being triggered. All you then do is set the high priority bit, on any other interrupt you want as high priority, and this one handler will be called for all the interrupts. However remember to check for INT_EXT, if using this route.

The automatic behaviour of the chip, in making INT_EXT high priority, if priorities are enabled, is the core reason for problems if you set 'HIGH_INTS=true', and then don't use any interrupts as high priority. The compiler only adds the handler code, once one interrupt is flagged as 'HIGH' but as soon as the priorities are enabled, INT_EXT, will be vectoring to the high priority handler. Since there is no handler present, disaster....

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