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模式,但定时器无法唤醒,请问大家知道是什么原因?
esp32-s3 进入light-sleep模式后无法定时器唤醒
esp32-s3 进入light-sleep模式后无法定时器唤醒
- Attachments
-
- 微信图片_20230424085829.png (238.87 KiB) Viewed 5787 times
Re: esp32-s3 进入light-sleep模式后无法定时器唤醒
这段代码和 light sleep 例程的代码一样,你这边跑例程能否正常唤醒?如果是的话得看你程序的其他地方是否造成了影响,得知道你整个程序的运行逻辑
Re: esp32-s3 进入light-sleep模式后无法定时器唤醒
只跑这个例程light_sleep_example_main.c也是不行,不知道是哪里导致这问题
- Attachments
-
- 微信图片_20230426140935.png (227.78 KiB) Viewed 5692 times
Re: esp32-s3 进入light-sleep模式后无法定时器唤醒
兄弟,这个问题解决了吗?我的也不能唤醒啊,GPIO和timer唤醒设置了都没用
Who is online
Users browsing this forum: No registered users and 39 guests