Pin configuration initial transition.

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
kotk_o
Posts: 10
Joined: Mon Mar 22, 2021 12:19 pm

Pin configuration initial transition.

Post by kotk_o » Mon Mar 22, 2021 12:25 pm

hello Team,

I have a little problem configuring the GPIOs with my own board using micropython. I check in the oscilloscope, that if you configure the a GPIO using these methods:

Code: Select all


pin23 = machine.Pin(23, machine.Pin.OUT)
pin23 = machine.Pin(23, machine.Pin.IN,machine.Pin.PULL_DOWN)
pin23 = machine.Pin(23, machine.Pin.OUT,0)
...works, however, a little transition of 150us, 0V -> 3.3V -> 0V, appears in the output of the GPIO.

How I can configure an output with initial value=0, without have this transition of 3.3V?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Pin configuration initial transition.

Post by pythoncoder » Mon Mar 22, 2021 6:29 pm

I don't know whether anyone has ever checked this before. It might be worth trying setting everything at once. Something like:

Code: Select all

pin23 = machine.Pin(23, machine.Pin.OUT, pull=machine.Pin.PULL_DOWN, value=0)
Peter Hinch
Index to my micropython libraries.

kotk_o
Posts: 10
Joined: Mon Mar 22, 2021 12:19 pm

Re: Pin configuration initial transition.

Post by kotk_o » Tue Mar 23, 2021 7:46 am

It doesn't work, the same happens. I think that I found a really big bug.

See image:
https://ibb.co/n6nVbMH

I'm using the micropython:
MicroPython v1.14 on 2021-02-02; ESP32 module with ESP32 and the output used is the GPIO22. This output is not connected to anything, only one cable to the oscilloscope. (I tried with other outputs, like GPIO23, the same happens)

This can cause multiple hardware failures if the developer doesn't know it. Usually, when you configure a GPIO as a output, the hardware must init the output to '0' (GND), but the problem of this bug is that it doesn't matter if you configure the GPIO as an INPUT or OUTPUT, or OPEN DRAIN or whatever, once configured, the GPIO do this transition.

I'm new on micropython, so i don't know how to contact to the micropython TEAM in order to fix it. I think that this is critical.

User avatar
Roberthh
Posts: 3668
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pin configuration initial transition.

Post by Roberthh » Tue Mar 23, 2021 9:46 am

It seems that there is indeed a bug, in that the Pins cannot be configured as Input without a pull set. The default is PULL_UP, and even when switching top PULL_DOWN, I see a short pulse of about 300µs. That is anyhow a problem, if you need an input with a high impedance.
Looking into the code, the problem starts with calling gpio_reset_pin() from the ESP_IDF. That sets the mode to input with pull-up enabled. So there are two problems:

- having alwas pull-up set, even for short time
- no way to disable a pull-up

In you case there would be a workaround. Since the internal pull-up has a rather high impedance of about 30kOhm, you could put a low load to the pin of about 470 Ohm (or less), reducing the transient spike level to about 50 mV. Nevertheless, I see a base offset of 160mV at the ESP output even with 470 Ohm load and PULL_DOWN set. So I end up with a worst case input level of 200mV.

kotk_o
Posts: 10
Joined: Mon Mar 22, 2021 12:19 pm

Re: Pin configuration initial transition.

Post by kotk_o » Tue Mar 23, 2021 10:43 am

Thank you for test it, Robert.

Now it make sense. I will try to fix it using pull down resistors.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Pin configuration initial transition.

Post by pythoncoder » Wed Mar 24, 2021 6:10 pm

It is a bug, however. The way to report it is to raise an issue on GitHub. Make sure you have a suitable title starting with ESP32 to ensure it gets attention from the appropriate developers.

5000 posts. Good grief. ;)
Peter Hinch
Index to my micropython libraries.

Post Reply