Skip to content

Commit af6cfc5

Browse files
committed
docs, examples: use rtc_gpio_isolate to disconnect GPIO12
This is needed to reduce deep sleep current on ESP32-WROVER modules. Ref TW18165.
1 parent f45622f commit af6cfc5

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

docs/api-reference/system/sleep_modes.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ The following function can be used to enter deep sleep once wakeup sources are c
122122

123123
.. doxygenfunction:: esp_deep_sleep_start
124124

125+
Configuring IOs
126+
---------------
127+
128+
Some ESP32 IOs have internal pullups or pulldowns, which are enabled by default. If an external circuit drives this pin in deep sleep mode, current consumption may increase due to current flowing through these pullups and pulldowns.
129+
130+
To isolate a pin, preventing extra current draw, call :cpp:func:`rtc_gpio_isolate` function.
131+
132+
For example, on ESP32-WROVER module, GPIO12 is pulled up externally. GPIO12 also has an internal pulldown in the ESP32 chip. This means that in deep sleep, some current will flow through these external and internal resistors, increasing deep sleep current above the minimal possible value.
133+
Add the following code before :cpp:func:`esp_deep_sleep_start` to remove this extra current:
134+
135+
```c++
136+
rtc_gpio_isolate(GPIO_NUM_12);
137+
```
138+
125139
Checking sleep wakeup cause
126140
---------------------------
127141

examples/system/console/main/cmd_system.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static int deep_sleep(int argc, char** argv)
113113

114114
ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) );
115115
}
116+
rtc_gpio_isolate(GPIO_NUM_12);
116117
esp_deep_sleep_start();
117118
}
118119

examples/system/deep_sleep/main/deep_sleep_example_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ void app_main()
157157
esp_sleep_enable_ulp_wakeup();
158158
#endif
159159

160+
// Isolate GPIO12 pin from external circuits. This is needed for modules
161+
// which have an external pull-up resistor on GPIO12 (such as ESP32-WROVER)
162+
// to minimize current consumption.
163+
rtc_gpio_isolate(GPIO_NUM_12);
164+
160165
printf("Entering deep sleep\n");
161166
gettimeofday(&sleep_enter_time, NULL);
162167

examples/system/ulp/main/ulp_example_main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ static void init_ulp_program()
6868
rtc_gpio_pullup_dis(gpio_num);
6969
rtc_gpio_hold_en(gpio_num);
7070

71-
/* Disable pullup on GPIO15, in case it is connected to ground to suppress
72-
* boot messages.
71+
/* Disconnect GPIO12 and GPIO15 to remove current drain through
72+
* pullup/pulldown resistors.
73+
* GPIO15 may be connected to ground to suppress boot messages.
74+
* GPIO12 may be pulled high to select flash voltage.
7375
*/
74-
rtc_gpio_pullup_dis(GPIO_NUM_15);
75-
rtc_gpio_hold_en(GPIO_NUM_15);
76+
rtc_gpio_isolate(GPIO_NUM_12);
77+
rtc_gpio_isolate(GPIO_NUM_15);
7678

7779
/* Set ULP wake up period to T = 20ms (3095 cycles of RTC_SLOW_CLK clock).
7880
* Minimum pulse width has to be T * (ulp_debounce_counter + 1) = 80ms.

examples/system/ulp_adc/main/ulp_adc_example_main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ static void init_ulp_program()
7474
/* Set ULP wake up period to 20ms */
7575
ulp_set_wakeup_period(0, 20000);
7676

77-
/* Disable pullup on GPIO15, in case it is connected to ground to suppress
78-
* boot messages.
77+
/* Disconnect GPIO12 and GPIO15 to remove current drain through
78+
* pullup/pulldown resistors.
79+
* GPIO15 may be connected to ground to suppress boot messages.
80+
* GPIO12 may be pulled high to select flash voltage.
7981
*/
80-
rtc_gpio_pullup_dis(GPIO_NUM_15);
81-
rtc_gpio_hold_en(GPIO_NUM_15);
82+
rtc_gpio_isolate(GPIO_NUM_12);
83+
rtc_gpio_isolate(GPIO_NUM_15);
8284
}
8385

8486
static void start_ulp_program()

0 commit comments

Comments
 (0)