Setting a RTC_GPIO in esp_wake_deep_sleep()

NRollo
Posts: 21
Joined: Fri Jan 22, 2021 1:04 pm

Setting a RTC_GPIO in esp_wake_deep_sleep()

Postby NRollo » Wed Aug 09, 2023 7:00 am

On a ESP32-D0WD module I am trying to set RTC_GPIO8 (GPIO33) in the esp_wake_deep_sleep() function using the esp-idf framework. This obviously means some REG_WRITE() and REG_READ() register "joggling".

So far I have come up with this (which apparently is not enough):
  1.     // Enable GPIO output
  2.     REG_WRITE(RTC_GPIO_ENABLE_W1TS_REG, REG_READ(RTC_GPIO_ENABLE_REG) | BIT(RTC_GPIO_ENABLE_W1TS_S + 8));
  3.  
  4.     // Set the GPIO output bit high
  5.     REG_WRITE(RTC_GPIO_OUT_W1TS_REG, REG_READ(RTC_GPIO_OUT_REG) | BIT(RTC_GPIO_OUT_DATA_W1TS_S + 8));
Can anyone give me at hint on what ESP32 registers to use right after deep sleep wakeup, in order to set GPIO33 (RTC_GPIO8) to high?

Thanks!

NRollo
Posts: 21
Joined: Fri Jan 22, 2021 1:04 pm

Re: Setting a RTC_GPIO in esp_wake_deep_sleep()

Postby NRollo » Wed Aug 09, 2023 8:56 am

I found a solution, this will do the trick:
  1. void RTC_IRAM_ATTR esp_wake_deep_sleep(void) {
  2.     // Output - set RTC mux
  3.     SET_PERI_REG_MASK(RTC_IO_XTAL_32K_PAD_REG, BIT(RTC_IO_X32N_MUX_SEL_S));
  4.  
  5.     // Output - clear the HOLD bit
  6.     CLEAR_PERI_REG_MASK(RTC_IO_XTAL_32K_PAD_REG, BIT(RTC_IO_X32N_HOLD_S));
  7.  
  8.     // Output - enable GPIO output
  9.     REG_WRITE(RTC_GPIO_ENABLE_W1TS_REG, BIT(RTC_GPIO_ENABLE_W1TS_S + GPIO_NUM_8));
  10.  
  11.     // Ouput - set the GPIO output high
  12.     REG_WRITE(RTC_GPIO_OUT_W1TS_REG, BIT(RTC_GPIO_OUT_DATA_W1TS_S + GPIO_NUM_8));
  13.     ets_delay_us(450000);
  14.     // Ouput - clear the GPIO output
  15.     REG_WRITE(RTC_GPIO_OUT_W1TC_REG, BIT(RTC_GPIO_OUT_DATA_W1TS_S + GPIO_NUM_8));
  16. }

Who is online

Users browsing this forum: No registered users and 106 guests