Page 1 of 1
Is it possible to enable Pulse Counter (PCNT) and gpio interrupt on the same pin?
Posted: Mon Sep 02, 2024 4:57 pm
by wuyuanyi
Hi, I am implementing a pulse counter for an encoder. I would also like to capture the edge in ISR and perform some action. However, when both PCNT and interrupt using `gpio_isr_handler_add`, the interrupt handler no longer gets called. I assume this was because the signal was routed to PCNT peripheral. Is it possible to enable both gpio isr and PCNT on the same pin?
Re: Is it possible to enable Pulse Counter (PCNT) and gpio interrupt on the same pin?
Posted: Tue Sep 03, 2024 2:42 am
by ESP_Sprite
Should be possible. In what order are you setting up the interrupt and the pulse counter? Can you swap that around?
Re: Is it possible to enable Pulse Counter (PCNT) and gpio interrupt on the same pin?
Posted: Tue Sep 03, 2024 5:13 am
by wuyuanyi
I have tried gpio_config > gpio_add_handler > pcnt setup as well as gpio_config > pcnt setup > gpio_add_handler. In either case,only pcnt works. the interrupt handler won't be called. Without pcnt the interrupt worked
Re: Is it possible to enable Pulse Counter (PCNT) and gpio interrupt on the same pin?
Posted: Tue Sep 03, 2024 7:55 am
by wuyuanyi
Welp, I could confirm that the correct combination to make PCNT and gpio interrupt work simultaneously is: PCNT setup -> gpio config -> gpio interrupt handler