Thanks to everyone who gave advice. I have the following options now. - Switch to F628 use CCP for triac gate pulses and use the left over cycles for debounce and other chores. - Spread debounce over multiple ISR calls. - Use vertical counter algorithm. - use register rotation method ( i haven't found out exactly what that is). For now I am going to experiment with the first two and see how that goes. I didn't check at the time but more featured F628 is actually cheaper than very basic and old F84. Depending on time, I will explore the other options too. Coming from big software engineering (Java, C++) back ground, I long to use C. But I will stick to advice given on this forum else where and stick to assembler. This will be my third and last project in assembler and then I am going to switch to C no matter what you say...yeah! :-) -Hasan ----- Original Message ---- > From: Hasan Khan > > 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. > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist