English
Language : 

AN921 Datasheet, PDF (7/24 Pages) Silicon Laboratories – Configurable Logic Unit
AN921: Configurable Logic Unit
Button Debounce
4. Button Debounce
In this section, we demonstrate how to use the Configurable Logic Units and Timer to build an automatic push button debounce logic to
automatically debounce button pushes and releases without any CPU or firmware intervention.
4.1 Background
Mechanical push buttons tend to generate multiple pulses when pressed or released, and some wireless IR signals may also tend to
exhibit this behavior when there is a change in state. Hence, it is normally necessary for an embedded system to debounce such sig-
nals so that a single press or release does not appear like multiple presses or releases. Typically, this task is performed in firmware and
can be prone to bugs if the firmware needs to handle other interrupts responsively. Button detection is normally a small part of the
system and should deserve only a bit of attention from firmware. In this section, a debounced button is implemented without firmware
resources or external hardware devoted to button debouncing.
In this implementation, a button is considered debounced if the output remains stable for specified amount of time. A timer keeps track
of the stabilization time, and the timer resets whenever the button state changes. If the stabilization time is reached, a bit readable by
firmware is updated to indicate the new, debounced button state. Firmware only needs to read the bit to determine to debounced button
state. Alternatively, changes in the debounced button state can trigger a interrupt to alert firmware that a button has been pressed.
BUTTON
(Pressed = 0)
BUTTON_DEBOUNCED
(Pressed = 0)
BUTTON_DEBOUNCED
(Pressed = 1)
<TSTABLE
TSTABLE
<TSTABLE
TSTABLE
Figure 4.1. Timing Diagram of Debounced Button (Simplified)
silabs.com | Smart. Connected. Energy-friendly.
Rev. 0.1 | 6