RTC_CLK_SRC_INT_8MD256 Causes Deep Sleep Wake-Up

hyunwook.lee
Posts: 3
Joined: Tue Feb 18, 2025 6:17 am

RTC_CLK_SRC_INT_8MD256 Causes Deep Sleep Wake-Up

Postby hyunwook.lee » Fri Mar 07, 2025 8:43 am

I'm using the ESP32-PICO-MINI-02 module in a system that repeatedly cycles between deep sleep and wake-up every 30 minutes. Initially, I used the default RTC clock source in IDF menuconfig, RTC_CLK_SRC_INT_RC, but I found that the time accuracy was very poor. Therefore, I decided to switch to RTC_CLK_SRC_INT_8MD256.

Component config -> Hardware Settings -> RTC Clock Config -> RTC clock source
RTC_CLK_SRC_INT_RC: Internal 150 kHz RC oscillator
RTC_CLK_SRC_INT_8MD256: Internal 8.5MHz oscillator, divided by 256 (~33kHz)

However, after changing the RTC clock source to RTC_CLK_SRC_INT_8MD256, I encountered an issue: after a soft reset (via the esp_restart function), the system fails to wake up from deep sleep. When I revert back to using RTC_CLK_SRC_INT_RC, the system wakes up normally.

I would like to use RTC_CLK_SRC_INT_8MD256 and have the system wake up correctly. Any help would be greatly appreciated.


Attached is my slip entry code below.
  1. void sleep_enter_deepsleep(uint32_t sleep_time, sleep_wakeup_source_e wakeup_source)
  2. {
  3.     isolate_rtc_gpio();
  4.  
  5.     struct timeval now;
  6.     gettimeofday(&now, NULL);
  7.  
  8.     if (sleep_time > 0) {
  9.         _target_wakeup_time.tv_sec = now.tv_sec + sleep_time;
  10.  
  11.     } else if (_target_wakeup_time.tv_sec < now.tv_sec) {
  12.         _target_wakeup_time.tv_sec = now.tv_sec + env_config_get__wakeup_intreval();
  13.     }
  14.  
  15.     int new_sleep_time = _target_wakeup_time.tv_sec - now.tv_sec - EARLY_WAKEUP_SEC;
  16.  
  17.     // minimum sleep time is 10 sec
  18.     new_sleep_time = (new_sleep_time < 10) ? 10 : new_sleep_time;
  19.  
  20.     if (wakeup_source == SLEEP_WAKEUP_TIMER || wakeup_source == SLEEP_WAKEUP_BOTH) {
  21.         // setup sleep time
  22.         esp_sleep_enable_timer_wakeup(new_sleep_time * 1000000LL); // esp_err_t -> ESP_ERR_INVALID_ARG
  23.         ESP_LOGI(TAG, "Entering DeepSleep, Timer: %ds", new_sleep_time);
  24.     }
  25.  
  26.     if (wakeup_source == SLEEP_WAKEUP_BUTTON || wakeup_source == SLEEP_WAKEUP_BOTH) {
  27.         // set wakeup source
  28.         rtc_gpio_pullup_en(GPIO_SW_INIT_B);
  29.  
  30.         gpio_set_direction(GPIO_SW_INIT_B, GPIO_MODE_INPUT);
  31.  
  32.         int gpio34_level = gpio_get_level(GPIO_SW_INIT_B);
  33.         ESP_LOGI(TAG, "GPIO 34 level before sleep: %d", gpio34_level);
  34.  
  35.         if (gpio34_level == 0)
  36.             ESP_LOGW(TAG, "GPIO 34 was LOW, err");
  37.  
  38.         // set wakeup source -> SW_INT_B (GPIO 34)
  39.         esp_sleep_enable_ext0_wakeup(GPIO_SW_INIT_B, 0); // trigger on falling edge
  40.     }
  41.  
  42.     gettimeofday(&_sleep_enter_time, NULL);
  43.     s_count++;
  44.     esp_deep_sleep_start();
  45. }

Who is online

Users browsing this forum: DrMickeyLauer, justinmreina and 119 guests