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

interrupt on change question

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







interrupt on change question
PostPosted: Tue Aug 02, 2005 4:55 am     Reply with quote

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
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 02, 2005 5:05 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Tue Aug 02, 2005 5:27 am     Reply with quote

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
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