How to read PWM duty and frequency from pin?

doglike
Posts: 63
Joined: Fri Aug 18, 2017 4:21 pm

How to read PWM duty and frequency from pin?

Postby doglike » Sun Apr 11, 2021 9:56 pm

Hi,

I want to read PWM duty and freq from GPIO22. I want to attach a sensor there, that measures 2 things and encodes that to duty (10-90%) and freq (50-250Hz) values.

Does anybody has an example code for me how to do that?

Thanks in advance!

ESP_morris
Posts: 290
Joined: Wed Sep 05, 2018 6:23 am

Re: How to read PWM duty and frequency from pin?

Postby ESP_morris » Mon Apr 12, 2021 4:46 am

MCPWM Capture feature can help you

doglike
Posts: 63
Joined: Fri Aug 18, 2017 4:21 pm

Re: How to read PWM duty and frequency from pin?

Postby doglike » Mon Apr 12, 2021 7:56 pm

Is there any example or a library?
Cannot find anything :(
For sure, I am not the first, who want to do something like this.

doglike
Posts: 63
Joined: Fri Aug 18, 2017 4:21 pm

Re: How to read PWM duty and frequency from pin?

Postby doglike » Tue Apr 13, 2021 8:49 am

Otherwise I have to go the "hard way" and implement edge-rising/falling interrupts + calculation of duty and freq.
Didn't expect, that there is nothing available :(

ESP_Minatel
Posts: 361
Joined: Mon Jan 04, 2021 2:06 pm

Re: How to read PWM duty and frequency from pin?

Postby ESP_Minatel » Tue Apr 13, 2021 8:54 am

Hi,

You can try on our docs here: MCPWM
And this example here: mcpwm_basic_config

Who is online

Users browsing this forum: Google [Bot], KallDrexx and 110 guests