warning icon  This site will be unavailable on Friday 21 February from 11:00AM to 5:00PM MST (1800 to 2400 UTC) for system maintenance.

How to Create a Debounce Circuit

Last modified by Microchip on 2025/01/02 09:09

Overview

Debounce and glitch filters are essential in digital systems to ensure clean, stable input signals. Mechanical buttons often produce noise or bounces due to their physical construction, where signal fluctuations occur as the contacts settle into a stable state. This can lead to unintended behavior, as systems may interpret each bounce as a separate input. Similarly, glitches caused by electrical noise or interference can further compromise signal integrity. Filters eliminate these issues, enhancing system reliability and performance.

Debounce Circuit in MPLAB Melody

Requirements

Procedure

Implement the CLB Logic

Configure the CLB to implement flip-flops, AND gates, or equivalent logic for the debounce/glitch filter. Refer to the block diagram for guidance.

Information

Note: If using MPLAB® Code Configurator (MCC), use the CLB Synthesizer tool or download the pre-configured CLB file.

Back to Top


Select a Clock Source for the CLB

Set the CLB to use the LFINTOSC clock source. This internal oscillator provides a stable frequency suitable for debounce timing.

Back to Top


Assign Pins

Connect the input to the debounce circuit to your button or switch. The debounced output signal from the circuit should be routed to your output pin.

Back to Top


Verify the Design

Confirm the debounce functionality using a debugging tool to ensure proper operation.

Back to Top

Results

The image shows a raw signal with noise caused by bouncing (green arrows) and the corresponding filtered signal. The debounce filter removes the noise by processing the signal at regular intervals, smoothing fluctuations to provide a stable and accurate representation of the input.

Debounce Circuit Waveform

Learn More

Back to Top