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

ext2 interrupt

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



Joined: 19 Nov 2003
Posts: 45
Location: Oxford

View user's profile Send private message Visit poster's website

ext2 interrupt
PostPosted: Tue Apr 06, 2004 9:14 am     Reply with quote

does anyone know the reason and how I can get out of this little prediciment

when I use ext_int_edge( 2, L_TO_H);

and enable_interrupts(INT_EXT2); it immediately goes to the interupt and doesn't wait for a change in state of pin_b2 to go from low to high

however when I do it the other way using ext_int_edge( 2, H_TO_L);

and enable the interupt it doesn't immediately go to the interupt it waits as it should until their is a tranistion from high to low on pin B2.

anyone got any experience with this.

its not a button de-bounce thing I have even left ten seconds before I enable the interupt and it still goes as soon as i set it
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: ext2 interrupt
PostPosted: Tue Apr 06, 2004 10:06 am     Reply with quote

homfray wrote:
does anyone know the reason and how I can get out of this little prediciment

when I use ext_int_edge( 2, L_TO_H);

and enable_interrupts(INT_EXT2); it immediately goes to the interupt and doesn't wait for a change in state of pin_b2 to go from low to high

however when I do it the other way using ext_int_edge( 2, H_TO_L);

and enable the interupt it doesn't immediately go to the interupt it waits as it should until their is a tranistion from high to low on pin B2.

anyone got any experience with this.

its not a button de-bounce thing I have even left ten seconds before I enable the interupt and it still goes as soon as i set it


Try this

Code:

clear_interrupt( INT_EXT2);
enable_interrupts(INT_EXT2);
homfray



Joined: 19 Nov 2003
Posts: 45
Location: Oxford

View user's profile Send private message Visit poster's website

PostPosted: Tue Apr 06, 2004 10:09 am     Reply with quote

on PCH I get the following error when I try that

Undefined identifier clear_interrupts
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Tue Apr 06, 2004 11:25 am     Reply with quote

homfray wrote:
on PCH I get the following error when I try that

Undefined identifier clear_interrupts


I'm using a later compiler version.

I get this
Code:
.................... clear_interrupt( INT_EXT2);
216C:  BCF    FF0.1
.................... enable_interrupts(INT_EXT2);
216E:  BSF    FF0.4


You can do that as an asembly instruction with an older version of the compiler. It will clear the interupt flag that is already set before you enable jumping to the interupt routine.
Ttelmah
Guest







PostPosted: Tue Apr 06, 2004 2:50 pm     Reply with quote

Neutone wrote:
homfray wrote:
on PCH I get the following error when I try that

Undefined identifier clear_interrupts


I'm using a later compiler version.

I get this
Code:
.................... clear_interrupt( INT_EXT2);
216C:  BCF    FF0.1
.................... enable_interrupts(INT_EXT2);
216E:  BSF    FF0.4


You can do that as an asembly instruction with an older version of the compiler. It will clear the interupt flag that is already set before you enable jumping to the interupt routine.

Really the 'safe sequence', is to read portB (so that the latch is reset), then clear the interrupt, then enable the interrupts.
If your compiler is too old to have the 'clear_interrupt' function, then simply use a #bit define for the interrupt bit, and set this to zero.

Best Wishes
homfray



Joined: 19 Nov 2003
Posts: 45
Location: Oxford

View user's profile Send private message Visit poster's website

PostPosted: Wed Apr 07, 2004 2:33 am     Reply with quote

Thanks you lot I really appreciate everything!!, it now works I have added

Header
Code:
#byte INTCON3 = 0xFF0
#bit RESET_INTERRUPT = INTCON3.1


Main Code
Code:
input_b();
RESET_INTERRUPT = 0;
enable_interrupts(INT_EXT2);


and it works how I planned (started to get worried for a while).

I am using PCH compiler 3.180 are you saying there is a newer version of the compiler with more commands such as clear_intterupt?

Once again thanks for all your help I really appreciate it. This is how a forum should be, a place where experience can be shared by people with the know in order to help people who would like to know Very Happy
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