Is it possible to enable Pulse Counter (PCNT) and gpio interrupt on the same pin?

wuyuanyi
Posts: 28
Joined: Wed Mar 09, 2022 11:54 am

Is it possible to enable Pulse Counter (PCNT) and gpio interrupt on the same pin?

Postby wuyuanyi » Mon Sep 02, 2024 4:57 pm

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?

ESP_Sprite
Posts: 9568
Joined: Thu Nov 26, 2015 4:08 am

Re: Is it possible to enable Pulse Counter (PCNT) and gpio interrupt on the same pin?

Postby ESP_Sprite » Tue Sep 03, 2024 2:42 am

Should be possible. In what order are you setting up the interrupt and the pulse counter? Can you swap that around?

wuyuanyi
Posts: 28
Joined: Wed Mar 09, 2022 11:54 am

Re: Is it possible to enable Pulse Counter (PCNT) and gpio interrupt on the same pin?

Postby wuyuanyi » Tue Sep 03, 2024 5:13 am

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

wuyuanyi
Posts: 28
Joined: Wed Mar 09, 2022 11:54 am

Re: Is it possible to enable Pulse Counter (PCNT) and gpio interrupt on the same pin?

Postby wuyuanyi » Tue Sep 03, 2024 7:55 am

Welp, I could confirm that the correct combination to make PCNT and gpio interrupt work simultaneously is: PCNT setup -> gpio config -> gpio interrupt handler

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], blim_acs and 126 guests