pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
196 stars 167 forks source link

Pull-down resistors (shouldn't be?) enabled at boot #571

Open marmotton opened 2 years ago

marmotton commented 2 years ago

Hello, It looks like the pull-down resistors are enabled when micropython starts. This was somewhat of a problem for my application as I always need 3.3V on some outputs unless requested by my software. I initially put a 47k external pull-up resistor but as the pull-downs were enabled the voltage was only around 1.2V. It now works with 2.2k pull-ups. (See forum: https://forum.pycom.io/topic/7312/how-to-avoid-enabling-pull-down-at-boot)

I'm not familiar with the micropython source code, but it looks like the pull-downs are enabled here: https://github.com/pycom/pycom-micropython-sigfox/blob/a37510c092bcec00671c924accb97dcdfa2f4b5d/esp32/mptask.c#L232 https://github.com/pycom/pycom-micropython-sigfox/blob/a37510c092bcec00671c924accb97dcdfa2f4b5d/esp32/mods/machpin.c#L113

In my opinion it would be better to keep the pins in the default state as defined in the ESP32 datasheet. One can then enable pull-downs in boot.py, maybe even with a "init_pins()" function to keep it simple. Or maybe add a function to configure the behavior similar to pycom.heartbeat_on_boot(), for backwards compatibility.

os.uname() : (sysname='GPy', nodename='GPy', release='1.20.2.r4', version='v1.11-ffb0e1c on 2021-01-12', machine='GPy with ESP32', pybytes='1.6.1')