QUERY · ISSUE
ESP32 Read PWM-GPIO Value
enhancement
Is it possible to implement a read back of the current gpio status for a pin that is driven by the pwm module? I would need it in combination with the @micropython.viper decorator.
from machine import Pin,PWM
p0 = Pin(0, Pin.OUT)
pwm = PWM(p0, freq=100, duty=512)
print(p0.value())
CANDIDATE · ISSUE
ESP32 Confusing behaviour of PWM after soft reset
port-esp32
Consider:
from machine import Pin, PWM
pin = Pin(23, Pin.OUT)
pwm = PWM(pin, freq=38000, duty=338)
This works as expected. If you issue ctrl-d the waveform on the pin continues unchanged. If you paste the above code again, you cause a low output with
pwm.duty(0)
Subsequently changing the duty value to a value > 0 has no effect. This is surprising.
There is a simple workround of issuing pwm.deinit() at the start. The current state could be confusing to newcomers. It should either be documented or changed so that a soft reset de-initialises any PWM instance.