← index #5696PR #5474
Related · high · value 2.525
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 · PULL REQUEST

esp8266: fix GPIO16 open drain mode

closedby marcin1jopened 2019-12-29updated 2022-11-15
port-esp8266

This adds a working open drain mode for GPIO16. Looks like the original plan to overcome the lack of (apparently missing) control register for open drain driver was to switch between input and output mode with low state.
In general this solution works well but control logic for GPIO_MODE_OPEN_DRAIN in set_pin() function was missing.

There's also a minor cleanup in mp_hal_pin_open_drain(). Setting output register value won't hurt, but is unnecessary.

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