??? 07/19/04 16:24 Read: times |
#74462 - RE: Push Button Bouncing Time Method Responding to: ???'s previous message |
"while (pushb != 0); // wait until button is
// pressed " So if push button port is never operated, will your MCU wait just there endlessley ? The proper approach would be : 1. Read Push button port. 2. Is it low ? If NO quit this routine. 3. If it is low, then start a timer for debounce_delay. 4. After debounce_delay is over, read push button port. 5. If it is still low, then you have a real signal. Process it as required. 6. If it is not low, then it is a false signal or is still debouncing. For the debounce_delay, you can start with about 20 ms delay. Should suffice mostly but can stretch upto 40ms or more at times depending on the condition of relay contacts / pusbutton contacts. PS: The above is one of several such methods and goes by the name of polling. Raghu |