You have failed to recognize a third state: Timer1 is running and overflows > 50. When the button is pressed, why not simply check if overflows is greater than 50? If so, reset the timer, if not (i.e. overflows <=3D 50), start/stop the timer. This assumes that one doesn't care if the timer needs to be running or not after the 50 overflows. If the start/stop is still required after the 50, the button would need to be pressed twice (first to stop the timer, then to reset it.) Unless I have completely misinterpreted your situation... -Scott On Wed, Apr 1, 2009 at 10:38 AM, Rikard Bosnjakovic wrote: > 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 =3D 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) =A0=3D= > =A0reset > * (If RA0 is pressed) AND (either state of Timer1) AND ( 0 < overflows > < 5) =3D> TMR1ON =3D 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? > > > -- > - Rikard - http://bos.hack.org/cv/ > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist