i am using the libgpiod to detect some buttons (in this example a PTT Button on an microphone) as inputs.
In my application i use the libgpiod-python API and noticed some weird behavior while detecting libgpiod-events. This leads to my software debouncing not detecting any button press if the last event is missing (at least this is my guess).
To exclude errors in my application, i try to show the problem with the default command line tools from libgpiod.
This is the event log of gpiomon detecting a single button press and release with some bouncing action. As you can see there are multiple sections multiple falling edge events follow after each other (which should not be possible in my understanding). Because of this i think there are missing events in between, or there is some problem with the libgpiod itself.
This is a screenshot from the oscilloscope at the button press:
I will try some additional hardware debouncing but i would like to prevent this libgpiod behavior in the first place.
Have you some tips or ideas why there are multiple falling edges after each other?
I have some more pushbuttons of a different type which i don’t want to RC-filter each. Those buttons seem to bounce way less, so i hope my application register all the pushes of them in the future. For the PTT button i am going to add the filter into the final design.
iMX7D GPIO can sense either falling or rising edge, but not both simultaneously. Changing sensitivity direction takes time and SW may loose events in that time. But application or perhaps libgpiod could check pin level after changing rising/falling mode and this way not lose last event.
I didn’t use gpiomon before. Why does it require unexported gpio in /sys/class/gpio ? It exits with error if pin is exported, even though direction is “in”.
Linux is not a real time OS, so if you have too many interrupts in a short time some of them can be missed. Could you try to connect an RC filter in parallel with your button?
Each GPIO input has a dedicated edge-detect circuit which can be configured through software to detect rising edges, falling edges, logic low-levels or logic high-levels on the input signals.
As well look around in registers. You will find settings for rising, for falling, but not for both simultaneously.