esp_light_sleep_start causes ESP_ERR_INVALID_STATE

Katagia
Posts: 1
Joined: Wed Jul 31, 2024 4:34 am

esp_light_sleep_start causes ESP_ERR_INVALID_STATE

Postby Katagia » Fri Aug 16, 2024 10:13 am

Hi

I use an ESP32-S3 board with LCD and GT911 touch. I want to use the light sleep function. The touch IRQ should be used for wakeup.

I use this shortend core, similar to the GPIO example for light sleep:

Code: Select all

    gpio_config_t config = {
            .pin_bit_mask = (1ULL<<GPIO_NUM_4),
            .mode = GPIO_MODE_INPUT,
            .pull_down_en = false,
            .pull_up_en = false,
            .intr_type = GPIO_INTR_DISABLE
    };
    gpio_config(&config);
    gpio_wakeup_enable(GPIO_NUM_4, GPIO_INTR_LOW_LEVEL );
    esp_sleep_enable_gpio_wakeup();
    /* Wait for pin to settle down. TODO: This could cause a stall. */
    while (gpio_get_level(GPIO_NUM_4) == 0) {
        vTaskDelay(pdMS_TO_TICKS(10));
    }
    /* Start light sleep. */
    err = esp_light_sleep_start();
    if (err != ESP_OK) {
        ESP_LOGI(RTC_TAG,"rtc_sleep: esp_light_sleep_start failed: %s", esp_err_to_name(err));
        return err;
    }
The problem is that esp_light_sleep_start() returns ESP_ERR_INVALID_STATE. I was able to narrow it down to the initialization of the touch controller. The wakeup pin is configured as input, PU, irq on fallind edge. Without this, the ESP32-S3 will go into light sleep.
Therefore, I tried to reset to GPIO before going into sleep. For this, I added the following code in front:

Code: Select all

    gpio_reset_pin(GPIO_NUM_4);
    gpio_intr_disable(GPIO_NUM_4);
    gpio_isr_handler_remove(GPIO_NUM_4);
This code doesn't help, ESP_ERR_INVALID_STATE is still thrown. What is the right way to reset the GPIO so I can use it as wakeup pin?

Thank you very much.

MicroController
Posts: 1541
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: esp_light_sleep_start causes ESP_ERR_INVALID_STATE

Postby MicroController » Tue Aug 20, 2024 9:48 pm

Katagia wrote:
Fri Aug 16, 2024 10:13 am
The problem is that esp_light_sleep_start() returns ESP_ERR_INVALID_STATE.
You may in fact be seeing an ESP_ERR_SLEEP_REJECT ...

Maybe try keeping the pull-up enabled in light sleep.

Who is online

Users browsing this forum: No registered users and 155 guests