espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.82k stars 7.32k forks source link

GPIO floating in light sleep (IDFGH-11184) #12351

Open eme-bennytang opened 1 year ago

eme-bennytang commented 1 year ago

Answers checklist.

General issue report

Hi,

I am trying out the lightsleep for my ESP32S3. I set a GPIO to High before going to sleep, but I found that when it enter sleep, the GPIO go down immediately. After some digging, seems the GPIO will be set to High Impedance after sleep?

Is there any way I can hold some IO to its original state (state before sleep) while sleeping?

Thanks

KonstantinKondrashov commented 1 year ago

Hi @eme-bennytang! You may take a look at this chapter in TRM 6.7 RTC IO MUX for Low Power and Analog Input/Output.

You can try to use gpio_hold_en() gpio_hold_dis().

gpio_hold_dis(num_pin);
...

gpio_set_level(num_pin, 0);
gpio_hold_en(num_pin);
esp_sleep_enable_timer_wakeup(30 * 1000); // 30 sec sleep
esp_light_sleep_start();
gpio_hold_dis(num_pin);
esp-wzh commented 1 year ago

@eme-bennytang If you are using autolight sleep controlled by esp_pm, It is recommended to use gpio_sleep_sel_dis to disable automatic switching of gpio mode when entering sleep, because if PM_SLP_DISABLE_GPIO or ESP_SLEEP_GPIO_RESET_WORKAROUND is enabled, the system will configure all gpio sleep modes to high impedance during startup.

refer: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/kconfig.html#config-pm-slp-disable-gpio

esp-wzh commented 9 months ago

If no more issues, this thread can be closed.