Hi,
I am looking for the debouncing function for switch in MPLAB XC8 that I can use with PIC 18F. Do they provide any library in MPLAB for debouncing ?
A retriggerable monostable multivibrator with
a timeout that exceeds the range of bounce-
interval, would be a piece-part solution - and
a model for code implementations.
There are literally thousands of code examples for this.
My favourite approach is the 10mS timer interrupt that polls the input pins (yes - this can be used for multiple input pins that need to be debounced) and keep record as a bit in a variable of the last value. If the current value is the same as the last one then set that in a variable that can be accessed by the main code as that will be the last debounced state of each pin.
(Pretty much the same as @barry's method but makes clear that you need a timer ISR, a couple of variables and can be used for multiple pis simultaneously.)
Susan