Button Debounce in Firmware

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
PhGi_2174146
Level 3
Level 3
First like received First like given

We're using an 20736S and we're trying to differentiate between a single, double, and triple button press.  We're getting some extra triggering of the interrupt on the button due to bouncing.  We do have a pull down resistor on the pin, and we're configuring the pin using gpio_configurePin (we're using P4 in this case) with:

GPIO_INPUT_ENABLE | GPIO_EN_INT_RISING_EDGE | GPIO_PULL_DOWN, GPIO_PIN_INPUT_LOW

We've also setup the port in the BLE_PROFILE_GPIO_CFG with:

GPIO_INPUT  | GPIO_INIT_LOW  | GPIO_BUTTON | GPIO_INT

It's my understanding that there's debouncing logic already in the firmware and we'd like to try to use that before writing our own.  Do we have to do anything special to use the firmware capability, or should we be using different configuration settings.  We've tried a variety of different settings but none seem to make a difference.

Thank you.

0 Likes
1 Solution

Thanks for the information!  It looks like we needed something that spanned more than a few milliseconds so we implemented our own that seems to be working fine.

Best,

Phill

View solution in original post

0 Likes
3 Replies
Anonymous
Not applicable

Hello Phill,

Have you checked the SDK 2.2:

pastedImage_0.png

Let me know if this helps

JT

0 Likes
MichaelF_56
Moderator
Moderator
Moderator
250 sign-ins 25 comments on blog 10 comments on blog

If you are using a raw GPIO, then you will need to implement all of the debouncing yourself.

However, if you use GPIO_BUTTON, firmware does a little debouncing 3-4ms.  If you need more, then you will need to run a state machine and start off a timer then wait for x number of ms, then check the condition and adjust debounce yourself.

0 Likes

Thanks for the information!  It looks like we needed something that spanned more than a few milliseconds so we implemented our own that seems to be working fine.

Best,

Phill

0 Likes