Take a look at the asm and "C" versions at the following site: http://www.piclist.com/techref/microchip/debounceK8LH.htm I just tried it out, and it works like a charm! I converted the switch handling on my current project to use it, and am very pleased. The original code is based on a timer that fires every 1 msec; the code handles things to actually do the testing every 8 msec. (every 8th time through the interrupt routine). You could modify the code to take out this loop, then have your 10ms interrupt handler include the modified code. The debounce time would now be 30 msec instead of the 24 msec in the original code. Larry Original Message: > Hi, Well, I am finally moving from hobby to pro zone. I got a simple project where I have to design a triac based ac power controller with two push buttons, one to increase power to triac and one to decrease power. Power level is displayed on a single 7-seg display. Hardware design is based on 16F84 because they are available dirt cheap here. Timing of the circuit it based around zero crossings which at 50 Hz happens at every 10ms. I have an ISR that does the following every zero crossing. - pulse triac gate at set time delay - read and act on button state - display power level on the display These steps can be done easily in 10ms except that doing software based switch debouncing needs longer than 20ms (10ms for switch down, 10ms for switch up). This results in ISR being called while still reading switches and ISR calls switch reading routine again and therefore I have recursion and a quick stack overflow error. How do I do switch debouncing here? Will a reduced debounce time of 8ms work? Is there a better software design? PS: The whole project is in simulation stage and no breadboarding done yet. Small size and low cost are important considerations so I can't do hardware debouncing. Thanks for your help. -- 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