← index #13021Issue #6275
Related · high · value 0.801
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

ESP32, PWM channel issues

closedby p1ng0oopened 2020-07-22updated 2020-07-22

Seems the ESP32 use the same channel for all pwms.

>>> import machine
>>> pw1 = machine.PWM(machine.Pin(0))
>>> pw2 = machine.PWM(machine.Pin(14))
>>> print(pw1, pw2)
PWM(0, freq=5000, duty=512) PWM(14, freq=5000, duty=512)
>>> pw1.freq(1000)
>>> print(pw1, pw2)
PWM(0, freq=1000, duty=512) PWM(14, freq=1000, duty=512)

Reading the pwm code for the esp32 port, it should use instead a map of an available channel per pin.

esp32spiram-idf3-20200722-unstable-v1.12-652-gcaaaa2b1f.bin

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