esp32-s3 进入light-sleep模式后无法定时器唤醒

james_tan
Posts: 2
Joined: Mon Apr 24, 2023 12:36 am

esp32-s3 进入light-sleep模式后无法定时器唤醒

Postby james_tan » Mon Apr 24, 2023 1:00 am

void enter_light_sleep_main(void)
{
esp_err_t err = ESP_OK;

while (true) {
esp_sleep_enable_timer_wakeup(5000000); //设置唤醒时间
esp_sleep_enable_gpio_wakeup(); //使能GPIO唤醒
ESP_LOGE(TAG,"Entering light sleep\n");
uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);//等待串口数据发送完毕
int64_t t_before_us = esp_timer_get_time(); //获取睡眠前的时间
esp_light_sleep_start(); //开启睡眠
int64_t t_after_us = esp_timer_get_time(); //在唤醒时候获取唤醒时候的时间
const char* wakeup_reason;
switch (esp_sleep_get_wakeup_cause()) { //获取唤醒源
case ESP_SLEEP_WAKEUP_TIMER:
wakeup_reason = "timer";
break;
case ESP_SLEEP_WAKEUP_GPIO:
wakeup_reason = "pin";
break;
case ESP_SLEEP_WAKEUP_UART:
wakeup_reason = "uart";
break;
default:
wakeup_reason = "other";
break;
}
ESP_LOGE(TAG,"Returned from light sleep, reason: %s, t=%lld ms, slept for %lld ms\n",wakeup_reason, t_after_us / 1000, (t_after_us - t_before_us) / 1000);
}

}

以上为进入light-sleep模式的代码,附件也有截图,在main函数里调用此代码能进入到light-sleep模式,但定时器无法唤醒,请问大家知道是什么原因?
Attachments
微信图片_20230424085829.png
微信图片_20230424085829.png (238.87 KiB) Viewed 5787 times

ESP_ICY
Posts: 404
Joined: Mon Aug 23, 2021 11:10 am

Re: esp32-s3 进入light-sleep模式后无法定时器唤醒

Postby ESP_ICY » Tue Apr 25, 2023 8:45 am

这段代码和 light sleep 例程的代码一样,你这边跑例程能否正常唤醒?如果是的话得看你程序的其他地方是否造成了影响,得知道你整个程序的运行逻辑

james_tan
Posts: 2
Joined: Mon Apr 24, 2023 12:36 am

Re: esp32-s3 进入light-sleep模式后无法定时器唤醒

Postby james_tan » Wed Apr 26, 2023 6:10 am

只跑这个例程light_sleep_example_main.c也是不行,不知道是哪里导致这问题
Attachments
微信图片_20230426140935.png
微信图片_20230426140935.png (227.78 KiB) Viewed 5692 times

lv_xiao
Posts: 1
Joined: Wed Oct 18, 2023 6:31 am

Re: esp32-s3 进入light-sleep模式后无法定时器唤醒

Postby lv_xiao » Fri Nov 10, 2023 8:22 am

兄弟,这个问题解决了吗?我的也不能唤醒啊,GPIO和timer唤醒设置了都没用

Who is online

Users browsing this forum: No registered users and 39 guests