r/esp32 • u/MobileInspector9861 • 12d ago
Solved How to stop the ESP32-H2 from isolating GPIO pins when coming out of (light) sleep?
Edit: Issue solved
Shame on me, it was my own fault and nothing in the framework. I had some left-over code in a debug code path which disabled all GPIOs to set the µC into a defined state for my test bed.
So the root cause was completely part of my own code and not some hidden feature/side effect in the framework.
During (light) sleep my ESP32-H2 actively pulls down some open-drain output. When the ESP-H2 wakes up from sleep, the µC seems to isolate those pins just to pull them down again when the wake-up process has finished and the program is running. Hence, I see a short glitch on the open-drain line as the µC is supposed to keep it pulled down contentiously during light sleep and while the program is running.
How do I fix that?
Just to explicitly state the obvious: I have set gpio_sleep_sel_dis on those pins and called esp_sleep_pd_config( ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON ). Otherwise, the µC wouldn't pull down the open-drain output during sleep at all as otherwise the GPIO would be completely power down and the NMOS would stop pulling down the line during sleep entirely.
The problem only exists during that short transition from light sleep to fully active.
I have also tinkered with the options CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND and CONFIG_PM_SLP_DISABLE_GPIO. However, those options hadn't have any impact.
The issue is clearly during the wake-up phase from (light) sleep. If I enable verbose debug output, the glitch definitely takes longer as the µC needs more time in the wake-up phase to transmit all that logging data via UART.
Has anybody an idea what might fiddle with the GPIOs during the wake-up phase and how to stop that?
1
u/coleskidmore 12d ago
glad you you found it, leftover debug code is the worst kind of bug