Code: Select all
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
rtc_gpio_pullup_en(GPIO_CTRL_WAKE);
rtc_gpio_pulldown_dis(GPIO_CTRL_WAKE);
esp_sleep_enable_ext1_wakeup_io(1 << GPIO_CTRL_WAKE, ESP_EXT1_WAKEUP_ANY_LOW);
On wake, I check esp_sleep_get_wakeup_cause() and act differently according to the cause.
This works perfectly most of the time, with cause ESP_SLEEP_WAKEUP_EXT1 or ESP_SLEEP_WAKEUP_TIMER being given when the GPIO event or timer occurs.
The problem occurs if a reset (or power-on) occurs. This gives a wakeup cause of 0 (as exected) but immediately after the device is put to sleep with esp_deep_sleep_start(), it wakes up again immediately, with cause = ESP_SLEEP_WAKEUP_EXT1.
It appears that the reset somehow latches an EXT1 interrupt.
I have consulted the ESP-IDF documentation and cannot see an explanation or a fix for this.
Can anyone explain?