Wake Stub not working with GPIO_35/RTC_GPIO5

PeteDD
Posts: 45
Joined: Sat Sep 24, 2022 5:22 pm

Wake Stub not working with GPIO_35/RTC_GPIO5

Postby PeteDD » Mon Sep 04, 2023 10:10 pm

I have a wake stub routine that works fine with GPIO_0/RTC_GPIO_11 but which will not work with GPIO_35/RTC_GPIO_5
The board I am using is the TTGO T-Display ESP32. It's schematic shows a pullup resistor on the push button input on GPIO_35.
I use the following and it works fine in the wake stub for GPIO_0/RTC_GPIO_11 but not for GPIO_35/RTC_GPIO_5.

Any ideas why? I think with might be in the REG_GET_FIELD but I am not finding much documentation on that (I assume it is out there, I just have not found it).
THANKS!

Code: Select all


#define PULSE_CNT_GPIO_NUM 0      
#define PULSE_CNT_RTC_GPIO_NUM  11

static void RTC_IRAM_ATTR wake_stub(void)
{
#define PULSE_CNT_IS_LOW() \
    ((REG_GET_FIELD(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT) & BIT(PULSE_CNT_RTC_GPIO_NUM)) == 0)
    
   if (PULSE_CNT_IS_LOW())
    {
        ESP_RTC_LOGI("wake stub: Pulse Pin is LOW");
    }
    else
    { // GPIO_0 must be HIGH
        ESP_RTC_LOGI("wake stub: Pulse Pin is HIGH");
    }
    // Set wakeup time in stub, if need to check GPIOs or read some sensor periodically in the stub.
    esp_wake_stub_set_wakeup_time(1 * 1000000); // wake every second

    // Print status.
    ESP_RTC_LOGI("wake stub: going to deep sleep");

    // Set stub entry, then going to deep sleep again.
    esp_wake_stub_sleep(&wake_stub);
  }

PeteDD
Posts: 45
Joined: Sat Sep 24, 2022 5:22 pm

Re: Wake Stub not working with GPIO_35/RTC_GPIO5

Postby PeteDD » Tue Sep 05, 2023 2:58 pm

changing this:

Code: Select all

rtc_gpio_set_direction_in_sleep(PULSE_CNT_GPIO_NUM, RTC_GPIO_MODE_INPUT_ONLY);
to this:

Code: Select all

rtc_gpio_set_direction(PULSE_CNT_GPIO_NUM, RTC_GPIO_MODE_INPUT_ONLY);
and removing this:

Code: Select all

rtc_gpio_hold_en(PULSE_CNT_GPIO_NUM);
all in app_main(), fixed things

The interesting thing that I can't explain is that without ANY of those lines, the code worked fine for GPIO_0 but not for GPIO_35.

Who is online

Users browsing this forum: No registered users and 108 guests