This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Improving the key debounce



On the TI demo apps, I noticed that increasing the switch denounce value has inconsistent results. The key may trigger sooner than the debounce value.

This is due to the stack scheduling an osal event timer in the ISRs. ISRs happen before the system clock and timers are updated. After starting the osal timer, the timer is immediately decreased by osalTimerUpdate(). The code is essentially trying to schedule something for the future while existing in the "past".

A workaround is, within the ISR, schedule an immediate event which then sets the debounce timer event. This will allow the osal task loop to update the system clock before attempting to set the debounce timer