← index #5696Issue #11156
Related · high · value 1.483
QUERY · ISSUE

esp8266: open drain PWM?

openby osresearchopened 2020-02-25updated 2020-03-03
port-esp8266

When driving a high-side switching transistor with an external pull-up resistor the Pin.OPEN_DRAIN output works well (with negative logic, so grounding the output turns it on and letting it float turns it off). The PWM module however has a comment that it explicitly disables the open drain, which prevents the transistor from being able to fully turn off: https://github.com/micropython/micropython/blob/master/ports/esp8266/esppwm.c#L387

Is there a reason to do this rather than leaving the pin in the mode configured by the python code?

CANDIDATE · ISSUE

rp2: OPEN_DRAIN and PWM doesn't work

closedby GuillaumeLeclercopened 2023-03-30updated 2023-03-30
bug
from machine import Pin, PWM
PIN_MOTOR = 0

motor = Pin(PIN_MOTOR, Pin.OPEN_DRAIN, value=1)
pwm_motor = PWM(motor)
pwm_motor.freq(10_000)

pwm_motor.duty_u16(0)
pwm_motor.duty_u16(2**16)

According to my oscilloscope this sets the pin to high instead of a drain. using high() and low without PWM works

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