How to avoid enabling pull-down at boot
-
Hello,
Two of the pins I'm using (P11 and P20) should stay at 3.3V. They should switch to 0V only when requested by the program.So I added a 47k pull-up resistor on each of these pins.
I now have the issue that on boot (after a reset) the pins are at 3.3V but then switch to 1.2V or so, which corresponds to having the internal pull-down resistors enabled. (internal pull-downs are 45k according to the ESP32 datasheet). I get the same voltage when enabling the pull-downs in the software.
If I add
Pin('P11', mode=Pin.IN, pull=Pin.PULL_UP)
toboot.py
, P11 stays at 1.2V for around 500ms and then goes back to 3.3V:* t=0 (reset): P11=3.3V * t=638ms: P11=1.25V * t=1.12s: P11=3.3V
I guess that micropython is enabling these pull-downs at boot, is there something I can do to avoid it ?
-
@Benjamin-Graf That seems to be done there. The reason is power saving, setting all pins to input mode with pull-down enabled.
-
I digged a bit in the micropython source code, it looks like (I might be missing something) the pull-downs are enabled by micropython. I filed an issue here: https://github.com/pycom/pycom-micropython-sigfox/issues/571
-
@robert-hh thanks a lot, I soldered 2.2k resistors and it works well, the pin voltage at boot goes down to 3.1V and the rest of my circuit behaves as expected.
I tried to make sense of the "ESP32 pin list" as well as section A.4. IO_MUX of the ESP32 datasheet. They both indicate that there should be no pull-up/down resistors enabled at boot and reset. I guess that either micropython does set them or that not all the ESP32 behave as described. So it is better to test this kind of things before ordering PCBs.
-
@Benjamin-Graf P11 aka GPIO22 is UART0_RTS, P22 aka GPIO33 is XTAL32k_Output. You may not be able to change that behavior. You could try the "bigger hammer" approach: use a smaller resistor value for the pull-up, like 4.7k or 2.2k. The ESP32 can drive these easily to 0. With 4.7k you'll get ~3V as interim voltage, which is a safe digital high level.