1.1 Existing Solutions

For debouncing of slow signals, the simplest hardware solution is to debounce with an external resistive-capacitive (RC) filter component to filter out quick pulse changes in order to keep clean edges for the microcontroller to process. This will require more onboard components, resulting in extra cost and size. On the other hand, software debounce solutions range from the simple to sophisticated algorithms. The simplest debouncing strategy is to read the debounce input signal by using a delay period, for example, every 50 ms up to 500 ms, and set a flag indicating the input's state. A read during the initial bounce period returns a zero or a one indicating the switch's indeterminate state. One downside is high power consumption since the device cannot be put to sleep while waiting for a delay.

This delay can be handled with a timer that interrupts the CPU at a regular rate, and it can partly release the CPU waiting for the delay. One downside of all these approaches is the slow response since the delay period has to be long enough to avoid multiple pulses recognized at one debouncing. There are enhanced approaches which have been developed to reduce the debounce time. For example, there is a so-called pattern-based debouncer method which takes the overall pattern of the switch's voltage output over a relatively long period of time into account. The intention is to improve the overestimating of the bounce timeout. It keeps track of which state the button is currently in and detects the debouncing at a fine-grain time period but requires some more code to realize the function.

Code Free Switch Debounce using TMR2 with HLT proposes a code-free solution, in which the very first switch activation is used to start the timer counting, ignoring any subsequent bouncing. Once the timer count reaches a predetermined value, the timer peripheral will produce a signaling event that can be used to indicate that a valid switch activation has been detected. It is performed on hardware with no code requirements other than setting up the CIPs and Timer 2. This approach is code-free and fast. The limitation is that it is the first pulse which is used to generate the debounced signal, with no identification whether it is a stable pulse or a noise pulse.