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

INT_RB and edge detection

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



Joined: 20 Dec 2006
Posts: 40
Location: Reading, UK

View user's profile Send private message

INT_RB and edge detection
PostPosted: Tue Feb 13, 2007 5:30 am     Reply with quote

I'm currently using the port B interrupt, INT_RB, to detect when a button is pushed. However, since the interrupt is enabled on both high to low and low to high transitions, for one button press, I get two interrupts.

Does anyone know of a way to make this interrupt only return with one of these edge transitions?
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

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

PostPosted: Tue Feb 13, 2007 5:45 am     Reply with quote

try using:
Code:
ext_int_edge( H_TO_L );

or
Code:
ext_int_edge( L_TO_H );


Cheers,
Jos
aodj



Joined: 20 Dec 2006
Posts: 40
Location: Reading, UK

View user's profile Send private message

PostPosted: Tue Feb 13, 2007 5:55 am     Reply with quote

I thought that only applied to the INT_EXT interrupt?
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

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

PostPosted: Tue Feb 13, 2007 9:08 am     Reply with quote

aodj wrote:
I thought that only applied to the INT_EXT interrupt?

You are right offcourse, I was to quick to answer, I'm Sorry.

What you could try is is adding a if(input(port)) { handling code } code.
I don't know of a way to make the interrupt handling only H_TO_L or L_TO_H transitions.

Hope this helps,
Jos
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

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

Re: INT_RB and edge detection
PostPosted: Tue Feb 13, 2007 10:34 am     Reply with quote

aodj wrote:
..Does anyone know of a way to make this interrupt only return with one of these edge transitions?


Easy, you can't. This is not an "edge" triggered interrupt. It is a mismatch interrupt. It is up to your interrupt handler to discard the case you are not interested in.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Ttelmah
Guest







PostPosted: Tue Feb 13, 2007 11:00 am     Reply with quote

As has already been said, you can't. However there might be another alternative. As well as the normal INT_EXT, you can use the CCP module as a 'cheating' way of getting another external interrupt if this is not already being used. Basically you program this in 'compare' mode, to interrupt on one 'count', and since the interrupt can be set to operate on the CCP pin being high, or low, you can generate the effect of another external interrupt pin!...

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 13, 2007 2:52 pm     Reply with quote

CCS has an example file that shows how to use push buttons with the
#int_rb interrupt. It gives the option of compiling it to detect a low-to-high
transition or a high-to-low transition. Here's the file location:
Quote:

c:\program files\picc\examples\Ex_Pbutt.c
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