← index #13021Issue #4758
Off-topic · high · value 0.163
QUERY · ISSUE

ESP32 Read PWM-GPIO Value

openby JohannesMaierhoferopened 2023-11-19updated 2023-11-20
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

pwm.deinit() can not close Pin if Duty Cycle set to 1023

closedby ghostopened 2019-05-07updated 2019-05-26
port-esp8266

Hi I was using the latest nightly built for esp8266 that is esp8266-20190430-v1.10-304-g8031b7a25. I setup GPIO Pin 5 as a PWM pin and set the frequency to 1000. the deinit() method works fine for all the other duty cycles except when the duty cycle is set to max 1023.

Code
from machine import Pin, PWM
pwm = PWM(Pin(5))
pwm.freq(1000)
pwm.duty(1023)
pwm.deinit()##Does not work in this case

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied