Dave Johnson wrote: > I was convinced there wasn't one (for this particular application): The > problem is that there are many possible "modes" of operation, and some of > them have very busy, longish loop times (lots of forking off to do other > things), while others are mostly waiting around for something to happen. > Additionally, in one of the modes this same button will need to generate > an interrupt to wake the PIC from sleep: polling obviously won't work > there (sorry I forgot to mention that 'til now). So it seemed to me that > a hardware debounce and "store" was the best, most straightforward > solution. But I'm open to suggestions. > > By the way, I fully expect that in some modes I may miss the occasional > press, if the user is pushing the button like crazy and I'm polling > infrequently. And that's OK. Try Scott's debounce technique (using vertical counters) to debounce your buttons. It is single pass (no looping) and can be placed in the timer interrupt or can be called once in a while. To toggle the state of the button, just do a xor on the last reading. Ex: movf switch,w ;assume 1 = on xorwf toggle_state Reggie