> -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of Rikard Bosnjakovic > Sent: 01 April 2009 15:39 > To: Microcontroller discussion list - Public. > Subject: [PIC] One button, three purposes > > I'm working on a Timer1-based project where a button should serve > three purposes: start the timer, stop the timer, reset the timer. > Implementing the start/stop alone is easy (TMR1ON = 1 ^ TMR1ON), but > I'm having serious problems figuring out how I can implement the reset > as well. > > What I have been playing around with is Timer0. As soon as RA0 is > pressed T0IE is set (cleared when RA0 is released), and the ISR counts > overflows. Later I have made logic based on the amount of > TMR0-overflows. > > This is how I want it to behave: > > * (If RA0 is pressed) AND (Timer1 is stopped) AND (overflows > 50) => > reset > * (If RA0 is pressed) AND (either state of Timer1) AND ( 0 < overflows > < 5) => TMR1ON = 1 ^ TMR1ON > > (50 overflows is a couple of seconds - no need to be exact) > > I have implemented both of these but I cannot make them work together. > Been wasting(?) two hours on this so I can't really think straight any > longer. > > Does anyone have suggestions for another approach other than use Timer0? Just to clarify, are you using the overflow counter to check how long the button is pressed, so a short press starts or stops the timer, and a long press resets it? Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist