krzychb wrote: ↑Fri May 26, 2017 6:23 am
Thanks @ESP_igrr!
Works great from both main program (using rtc_gpio_hold_en / dis) and from ULP (using individual registers and bits).
EDIT:
A short description how to use hold enable / disable functionality together with an ULP program is available under
https://github.com/krzychb/ulp-loop
Hi @krzychb, I have studied and tested your example code and it is very usefull to understand deep-sleep and RTC GPIOs.
I have a question: in my case I need to put in hybernation (i.e. deep-sleep within only RTC timer, no slow/fast memory, no ULP) retaining GPIO23 (which is not RTC).
I have written a very simple test:
Code: Select all
main(){
printf("RESET:%d;wake:%d\n", rtc_get_reset_reason(0), esp_sleep_get_wakeup_cause());
//wait start
uint8_t cnt=0;
while (cnt < 3)
{
printf("startWait:%d\n", cnt);
vTaskDelay(pdMS_TO_TICKS(1000));
cnt++;
}
//Config gpio_num_23
gpio_config_t config = {
.pin_bit_mask = BIT64(GPIO_NUM_23),
.mode = GPIO_MODE_OUTPUT,
.pull_up_en = GPIO_PULLUP_DISABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE
};
ESP_ERROR_CHECK(gpio_config(&config));
cnt = 0;
while (cnt < 3)
{
printf("After config:%d\n", cnt);
vTaskDelay(pdMS_TO_TICKS(1000));
cnt++;
}
// Wake up in 5 seconds
esp_sleep_enable_timer_wakeup(5000000);
printf("set LOW GPIO_NUM_23 and HOLD\n");
gpio_set_level(GPIO_NUM_23,0);
gpio_deep_sleep_hold_en();
printf("going to DEEP SLEEP\n");
esp_deep_sleep_start();
}
GPIO_NUM_23 is retained during deep sleep as expected but when ESP32 wake up (I checked from rtc_get_reset_reason(0) which is "DEEPSLEEP_RESET" and esp_sleep_get_wakeup_cause() which is "ESP_SLEEP_WAKEUP_TIMER")
the pin goes high (I guess for its internal pull-up) until the "gpio_config" function is called.
Is it mandatory to introduce a wake stub in order to retain the GPIO level after wake-up from deep sleep?
Thanks