PWM in 1.18 has changed
Posted: Fri Jan 21, 2022 10:34 pm
The 1.18 update is great but I am having trouble getting PWM to work on esp32's with 1.18. I looked at the source and see that it has gone through a major update/upgrade from 1.17 to 1.18 but am not a c++ programmer. I am using the following simple code to test PWM:
import machine
xx = machine.Pin(23, machine.Pin.OUT)
yy = machine.PWM(xx, freq=1, duty=512)
On two separate esp32's with 1.17 that I have this code produces a nice square wave on the pin 23. On both of the esp32's the pins flat-line with the same code when updated to 1.18.
I have looked at the doc (great job with the update) and see that options have been added/changed for 'duty' on PWM with 1.18. One piece of info that may help figuring this out is that no matter what/how I try to change the duty value it always comes up zero:
PWM(Pin(23), freq=1, duty_u16=0, resolution=19, (duty=0.00%, resolution=0.000%), mode=0, channel=0, timer=0)
I have tried yy.duty_u16(16384), yy.duty(512) and the yy.duty() always shows 0.
import machine
xx = machine.Pin(23, machine.Pin.OUT)
yy = machine.PWM(xx, freq=1, duty=512)
On two separate esp32's with 1.17 that I have this code produces a nice square wave on the pin 23. On both of the esp32's the pins flat-line with the same code when updated to 1.18.
I have looked at the doc (great job with the update) and see that options have been added/changed for 'duty' on PWM with 1.18. One piece of info that may help figuring this out is that no matter what/how I try to change the duty value it always comes up zero:
PWM(Pin(23), freq=1, duty_u16=0, resolution=19, (duty=0.00%, resolution=0.000%), mode=0, channel=0, timer=0)
I have tried yy.duty_u16(16384), yy.duty(512) and the yy.duty() always shows 0.