Easiest will be to look for the inputs in an interrupt handler every 10ms. finding 10 consecutive same results would result in a button press.
When you use Capsense instead, de-bouncing is handled by the component.
Maybe you can tell me what's wrong here. I'm having trouble deciphering the TCPWM Timer Counter data sheet and using ReadCounter variables just for debugging, I can't seem to make it actually count Up or Down, let alone actually toggle an interrupt. Just to give some insight on what's going on: I have 2 buttons on a bus to a Debouncer Component. The results of 'q' are '1' or '2' if either button is pressed, '3' (both are high-pinned) if not. This way, I can debounce one of the 2 buttons, then use the Timer to start and define a click/hold type and associate it with the active button.
1 of 1 people found this helpful
Your input frequency to the TCPWM is 25kHz, the period is set to 60000. So interrupts will occur only every 2.4s which is probably not what you want. I would suggest to build an internal clock which is updated every 1 to 10 ms using a timer and incrementing a ms-counter. This timebase you can easily use to setup some software logic to decide how long a button is pressed.