wiring analogWrite() function does not respect previously set pinMode() #7836
Labels
waiting for feedback
Waiting on additional info. If it's not received, the issue may be closed.
8000
Basic Infos
Platform
Settings in IDE
Problem Description
The circuit I'm using the NodeMCU in requires PWM open-drain outputs. Even when setting the outputs to open-drain via pinMode(), passing OUTPUT_OPEN_DRAIN, the analogWrite() function resets the output to push-pull mode (OUTPUT).
The problem can be found in line 65 of the source file Arduino/cores/esp8266/core_esp8266_wiring_pwm.cpp (in the current master branch), where the pinMode() is reset to OUTPUT, regardless of what was previously set via this method.
To reproduce the problem, the sketch below can be run, with the output pin connected via a pull-down resistor (10k) to ground, and an oscilloscope connected to the output. The output should stay at 0V all the time (as pwm should either connect the output to GND, or leave it open, where the pull-down resistor would keep it at GND potential, if open-drain was respected). The observed output transitions between 0V and 3V3, as corresponds to a push-pull output configuration.
MCVE Sketch
Debug Messages
The text was updated successfully, but these errors were encountered: