Hi all,
I have been planning some code but along the way I've discovered the Pulse Counter (PCNT) and I'm wondering if there's a simpler way...
- Objective - When an input goes to High, and the pulse is at least 50ms long, record that as an event and include the timestamp (microseconds).
- Previous intent - Capturing all events and using a queue whilst comparing timestamps to filter out pulses that were under 50ms
- Potentially a better way? - Use PCNT, with the interrupt adding the timestamp to the queue, and a glitch filter with a max of 50ms
Would this be a better approach? Very new to ESP32.
Thanks.
Using PCNT as both filter and interrupt trigger
-
- Posts: 1709
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Using PCNT as both filter and interrupt trigger
Simple idea: On the rising edge of the input (GPIO interrupt?), start a 50ms (single-shot) timer which, upon expiry, will call code to handle a valid signal. On a falling edge of the input, stop/cancel the timer. It is permissible to "stop" a timer that already expired and in that case it just does nothing.
Who is online
Users browsing this forum: Majestic-12 [Bot] and 78 guests