![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
guest Guest
|
interrupt on change question |
Posted: Tue Aug 02, 2005 4:55 am |
|
|
Hi,
When using the interrupt on change feature is there a way to register the interrupt if a user holds the button down? In other words, I want the buttons to interrupt on a single push and also to scroll if the button is held down.
I realize this can be done with out interrupts. I'm wondering if the condition that causes the interrupt can be toggled in some way.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Aug 02, 2005 5:05 am |
|
|
Maintain the state of the port inside the interrupt (you have to declare the var as static). Look for changes on the bits that you are interrested in. You can decide whether to act on the rising or falling edges. Set flags and process them in main. You can also set a variable used as a count down timer. Decrement this variable through a timer interrupt and when it reaches 0 then set a flag for your scrolling action.
This post might be of interest as well
http://www.ccsinfo.com/forum/viewtopic.php?t=22145&highlight=button |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Aug 02, 2005 5:27 am |
|
|
One way, would be to have the interrupt on change, look at the 'edge' involved. If the key has gone active, start a timer interrupt, which triggers a 'key event', whenver it interrupts. If the key has gone inactive, stop this interrupt.
This is also good for another reason. If you use a timer hose period you can easily change (like timer2), then on the first active edge, you trigger the timer with a short timeout (perhaps 1/10th second). When this fires, you return the key as 'seen', and change the timer interval to perhaps 1/2 second. The key change interrupt code, then only contains the code to start the interrupt with the short time when the key is seen going active, and to disable the timer when the key goes inactive. This then gives 1/10th second 'debounce', and 0.5 second 'repeat' (or whatever times you program).
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|