howto: pwm(): Setting output to open drain (collector)
Posted: Thu Jun 29, 2017 8:35 am
Hi Team,
I am using a LED driver (dc-dc) with pwm modulation, which has its own pull up resistor at the pwm input,
resulting in the requirement to just pull down the signal, without active high.
Trick: In file esp8266\hardware\esp8266\VERSION\cores\esp8266\core_esp8266_wiring_pwm.c,
function extern void __analogWrite(uint8_t pin, int value) { ...
change line:
pinMode(pin, OUTPUT);
to
pinMode(pin, OUTPUT_OPEN_DRAIN);
I am using a LED driver (dc-dc) with pwm modulation, which has its own pull up resistor at the pwm input,
resulting in the requirement to just pull down the signal, without active high.
Trick: In file esp8266\hardware\esp8266\VERSION\cores\esp8266\core_esp8266_wiring_pwm.c,
function extern void __analogWrite(uint8_t pin, int value) { ...
change line:
pinMode(pin, OUTPUT);
to
pinMode(pin, OUTPUT_OPEN_DRAIN);