All GPIO pads do not hold logic level in Deep sleep
Posted: Thu Aug 10, 2017 2:56 pm
ESP32 technical reference manual contains a sub chapter "4.7 Pad Hold Feature". According to content each gpio can hold logic level irrespective of other behavior. We are configuring GPIOs and going into deep sleep. But what we have observed is that only GPIO pads which are in the RTC domain hold the logic level set before going to sleep mode. The other gpio pads do not hold the logic.
If we follow the technical reference manual, this seems to be a wrong behavior.
Could you please provide more information on this?
Pasting the code below for reference -
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "soc/rtc_io_reg.h"
#include "soc/sens_reg.h"
#include "esp_deep_sleep.h"
#include "rom/gpio.h"
#define GPIO2_RTC_DOMAIN 2
#define GPIO22_NONRTC_DOMAIN 22
#define GPIO_OUTPUT_PIN_SEL ((1<<GPIO2_RTC_DOMAIN) | (1<<GPIO22_NONRTC_DOMAIN) )
static void Init_IO(void)
{
gpio_config_t io_conf;
//disable interrupt
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
//set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = GPIO_OUTPUT_PIN_SEL;
//disable pull-down mode
io_conf.pull_down_en = 0;
//disable pull-up mode
io_conf.pull_up_en = 0;
//configure GPIO with the given settings
gpio_config(&io_conf);
gpio_set_level(GPIO2_RTC_DOMAIN, 1);
gpio_set_level(GPIO22_NONRTC_DOMAIN,1);
}
void app_main()
{
Init_IO();
ets_delay_us(1000);
gpio_pad_select_gpio(GPIO2_RTC_DOMAIN);
gpio_pad_pullup(GPIO2_RTC_DOMAIN);
gpio_pad_hold(GPIO2_RTC_DOMAIN);
gpio_pad_select_gpio(GPIO22_NONRTC_DOMAIN);
gpio_pad_pulldown(GPIO22_NONRTC_DOMAIN);
gpio_pad_hold(GPIO22_NONRTC_DOMAIN);
esp_deep_sleep_start();
}
Note: In deep sleep GPIO 2 hold the logic high, whereas GPIO 22 loses its set level.
If we follow the technical reference manual, this seems to be a wrong behavior.
Could you please provide more information on this?
Pasting the code below for reference -
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "soc/rtc_io_reg.h"
#include "soc/sens_reg.h"
#include "esp_deep_sleep.h"
#include "rom/gpio.h"
#define GPIO2_RTC_DOMAIN 2
#define GPIO22_NONRTC_DOMAIN 22
#define GPIO_OUTPUT_PIN_SEL ((1<<GPIO2_RTC_DOMAIN) | (1<<GPIO22_NONRTC_DOMAIN) )
static void Init_IO(void)
{
gpio_config_t io_conf;
//disable interrupt
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
//set as output mode
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = GPIO_OUTPUT_PIN_SEL;
//disable pull-down mode
io_conf.pull_down_en = 0;
//disable pull-up mode
io_conf.pull_up_en = 0;
//configure GPIO with the given settings
gpio_config(&io_conf);
gpio_set_level(GPIO2_RTC_DOMAIN, 1);
gpio_set_level(GPIO22_NONRTC_DOMAIN,1);
}
void app_main()
{
Init_IO();
ets_delay_us(1000);
gpio_pad_select_gpio(GPIO2_RTC_DOMAIN);
gpio_pad_pullup(GPIO2_RTC_DOMAIN);
gpio_pad_hold(GPIO2_RTC_DOMAIN);
gpio_pad_select_gpio(GPIO22_NONRTC_DOMAIN);
gpio_pad_pulldown(GPIO22_NONRTC_DOMAIN);
gpio_pad_hold(GPIO22_NONRTC_DOMAIN);
esp_deep_sleep_start();
}
Note: In deep sleep GPIO 2 hold the logic high, whereas GPIO 22 loses its set level.