English
Language : 

AN921 Datasheet, PDF (8/24 Pages) Silicon Laboratories – Configurable Logic Unit
AN921: Configurable Logic Unit
Button Debounce
4.2 Button Debounce Implementation
To implement the debounced button, two CLUs, one timer, and one GPIO pin is required. Timer 2 is used for a 10 ms stabilization time,
and the stabilization time can be adjusted. The timing diagram can now be expanded to include Timer 2.
BUTTON
(Pressed = 0)
Timer 2 Overflow
(T2OVF)
BUTTON_DEBOUNCED
(Pressed = 1)
Timer 2 Reload Force
(Run = 0)
ABC
D
<10ms 10ms
EFG
H
<10ms 10ms
Figure 4.2. Timing Diagram of Debounced Button (Expanded)
The timing diagram shows the following events during a button press:
• A: Button press triggers Timer 2 to run, beginning the 10 ms timer.
• B: Button bounces high, triggering Timer 2 to stop, and DEBOUNCED_BUTTON is unchanged
• C: Button bounces low, triggering Timer 2 to run and beginning the 10 ms timer
• D: Timer 2 overflows indicating BUTTON has stabilized, triggering the update of the BUTTON_DEBOUNCED state, and Timer 2
stops
Similarly, the timing diagram shows the following events during a button release:
• E: Button release triggers Timer 2 to run, beginning the 10 ms timer.
• F: Button bounces low, triggering Timer 2 to stop, and DEBOUNCED_BUTTON is unchanged
• G: Button bounces high, triggering Timer 2 to run and beginning the 10 ms timer
• H: Timer 2 overflows indicating BUTTON has stabilized, triggering the update of BUTTON_DEBOUNCED state, and Timer 2 stops
The following block diagram implements the timing diagram above.
CLU1
MXA
T2OVF
DQ
CLU2
BUTTON_
DEBOUNCED
MXB
BUTTON
MXA
Figure 4.3. Block Diagram of Debounced Button
Timer 2 Reload
Force
The BUTTON, Timer 2 overflow, BUTTON_DEBOUNCED, and Timer 2 Reload Force signals must be assigned to CLU inputs and out-
puts. BUTTON must be a GPIO pin, so it is assigned in CLU2's MXA input. Timer 2 can be reloaded by a CLU output, so it is assigned
to the CLU2 output.
A CLU output rising or falling edge can trigger an interrupt, so BUTTON_DEBOUNCE is assigned to the CLU1 output. Since BUT-
TON_DEBOUNCED updates on the rising the Timer 2 overflow, the CLU1 D flip-flop is used, with the Timer 2 overflow as the clock and
the inverted BUTTON_DEBOUNCE as the input. The CLU1 LUT implements the inversion with BUTTON_DEBOUNCE assigned to
CLU1's MXA input.
silabs.com | Smart. Connected. Energy-friendly.
Rev. 0.1 | 7