-->
Page 1 of 2

Use of D0 GPIO16 as PWM

PostPosted: Thu Dec 10, 2020 3:23 pm
by RIN67630
Hi,
i am just discovering that D0 GPIO16 cannot provide PWM.
I did no know that, and used it as a PWM output without problem.
It works nevertheless. What can happen, will i go to hell after my death?

Re: Use of D0 GPIO16 as PWM

PostPosted: Fri Dec 11, 2020 4:46 am
by btidey
The esp8266 does not have PWM hardware so it is implemented in software using timer functions to toggle GPIO.

As such there is no intrinsic restriction on which GPIO pin can be used but is more determined by what the software environment supports. Arduino ESP8266 has supported all pins including GPIO16 for a number of years.

Where did you see it say it was not supported?

Re: Use of D0 GPIO16 as PWM

PostPosted: Fri Dec 11, 2020 7:00 am
by RIN67630
> Where did you see it say it was not supported?

Thank you for your reply.
I found that:
https://randomnerdtutorials.com/esp8266 ... nce-gpios/

Re: Use of D0 GPIO16 as PWM

PostPosted: Sat Dec 12, 2020 12:48 pm
by StanJ
GPIO16 is part of the RTC section, so writing to it is much slower than writing to any other GPIO as the PWM core has to use API calls instead of GPOC/GPOS to set the pin high or low. It will work, but may not hit the same maximum speed as the other pins.

Additional, in a quick test here I get what appears to be WDT resets (can't tell, random garbage even at 74880 baud) if I run multiple PWM channels with GPIO16 as one of the channels. I'm even getting that garbage/reboot with a single PWM channel on GPIO16 occasionally, so "not recommended at the moment".