View previous topic :: View next topic |
Author |
Message |
aodj
Joined: 20 Dec 2006 Posts: 40 Location: Reading, UK
|
INT_RB and edge detection |
Posted: Tue Feb 13, 2007 5:30 am |
|
|
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
|
|
Posted: Tue Feb 13, 2007 5:45 am |
|
|
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
|
|
Posted: Tue Feb 13, 2007 5:55 am |
|
|
I thought that only applied to the INT_EXT interrupt? |
|
|
Foppie
Joined: 16 Sep 2005 Posts: 138 Location: The Netherlands
|
|
Posted: Tue Feb 13, 2007 9:08 am |
|
|
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
|
Re: INT_RB and edge detection |
Posted: Tue Feb 13, 2007 10:34 am |
|
|
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
|
|
Posted: Tue Feb 13, 2007 11:00 am |
|
|
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
|
|
Posted: Tue Feb 13, 2007 2:52 pm |
|
|
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 |
|
|
|
|