完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我对 ESP32-C3 进入 light-sleep 和从 light-sleep 唤醒需要多长时间很感兴趣,但我找不到任何发布的内容,所以我做了一些实验。我想我会在这里为其他人发布结果。
我写了一些代码进入进入 Light-Sleep 的循环,然后在 GPIO (4) 变高时醒来。我还在这个过程中设置了另一个 GPIO (13),这样我就可以在我的示波器上查看时序。 这是基本循环。它在以 160 MHz 运行的 ESP32-C3 开发板上使用 Arduino 环境以及一些 IDF API 调用。 代码:全选 // Go into an infinite loop of Light-Sleeps waiting on a GPIO to wake us up. // - GPIO04 - Wake-up Pin - Feed 100 Hz (3.3V) into this // - This is level based, so it will wake up as long as it is high. // - If it is already high, we will wake up right away. // - GPIO13 - Sleep-Indicator pin uint32_t CpuCountS; // Count of CPU cycles uint32_t CpuCountE; uint64_t MicrosS; // From ESP microseconds timer uint64_t MicrosE; pinMode(GPIO_NUM_4, INPUT); pinMode(GPIO_NUM_13, OUTPUT); gpio_wakeup_enable(GPIO_NUM_4, GPIO_INTR_HIGH_LEVEL); // Enable wakeup on high-level on GPIO 4 esp_sleep_enable_gpio_wakeup(); // Enable wake-up via GPIO pin level // Infinite loop for (uint16_t i; ; i++) { while (digitalRead(GPIO_NUM_4) == HIGH) {} // Loop until the pin is low since we don't want to wake up right away MicrosS = esp_timer_get_time(); CpuCountS = cpu_hal_get_cycle_count(); GPIO.out_w1ts.out_w1ts = (1 << GPIO_NUM_13); // Extra-fast - Set HIGH esp_light_sleep_start(); GPIO.out_w1tc.out_w1tc = (1 << GPIO_NUM_13); // Extra-fast - Set LOW CpuCountE = cpu_hal_get_cycle_count(); MicrosE = esp_timer_get_time(); printf("Sleep wake-up via GPIO after: %10.6f secs clock. %10.6f secs CPU.n", (MicrosE - MicrosS)/1000000.0, (CpuCountE - CpuCountS)/(1000000.0 * 160)); } // Cleanup wakeup settings even though this will never be executed in this code. esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_GPIO); gpio_wakeup_disable(GPIO_NUM_4); 然后我将大约 100 Hz 的方波馈入 GPIO 4,并观察 GPIO 13 以查看 ESP 何时进入和退出睡眠模式。 我进行一系列测量的笔记是: 代码:全选 Light Sleep Timing Data - Going to sleep: + 0 us - GPIO13 goes high - Just before the Sleep call. +320 us - GPIO 13 goes Hi-z - Voltage drops to Vcc/2 in a couple of us. - Drops to zero in < 5us when pulled low by 20K ohms +600 us - Drops to zero loaded with a 1x scope probe. +900 us - Drops to zero loaded with a 10x scope probe. - Basically, sleep is entered about 320 us after the esp_light_sleep_start() call. - Waking up: + 0 us - GPIO 4 goes high to wake up the ESP32 +280-290 us - GPIO 13 goes high again as pin returns to output-high from hi-z sleep mode +490-500 us - GPIO 13 goes low, set by code immediately after sleep returns. - The time returned by esp_timer_get_time() pretty accurately measures the true elapsed time including the sleep period. - The time returned by cpu_hal_get_cycle_count() is always about 250 us over the sleep period regardless of the sleep length. - That seems to be how long the CPU actually executes during the sleep entry and exit. 所以最重要的是,进入 Light Sleep 模式大约需要 320 us,然后大约需要 500 us 才能恢复正常执行。信号中有大约 10-20us 的抖动。 以下是串行控制台的几行: 代码:全选 Sleep wake-up via GPIO after: 0.000989 secs clock. 0.000244 secs CPU. Sleep wake-up via GPIO after: 0.001002 secs clock. 0.000243 secs CPU. Sleep wake-up via GPIO after: 0.000995 secs clock. 0.000249 secs CPU. Sleep wake-up via GPIO after: 0.001001 secs clock. 0.000250 secs CPU. Sleep wake-up via GPIO after: 0.000992 secs clock. 0.000250 secs CPU. Sleep wake-up via GPIO after: 0.001000 secs clock. 0.000250 secs CPU. Sleep wake-up via GPIO after: 0.000994 secs clock. 0.000245 secs CPU. Sleep wake-up via GPIO after: 0.000993 secs clock. 0.000245 secs CPU. Sleep wake-up via GPIO after: 0.001002 secs clock. 0.000243 secs CPU. Sleep wake-up via GPIO after: 0.001003 secs clock. 0.000249 secs CPU. Sleep wake-up via GPIO after: 0.001000 secs clock. 0.000251 secs CPU. Sleep wake-up via GPIO after: 0.000993 secs clock. 0.000251 secs CPU. Sleep wake-up via GPIO after: 0.001001 secs clock. 0.000250 secs CPU. Sleep wake-up via GPIO after: 0.000989 secs clock. 0.000244 secs CPU. Sleep wake-up via GPIO after: 0.000995 secs clock. 0.000245 secs CPU. Sleep wake-up via GPIO after: 0.001002 secs clock. 0.000244 secs CPU. Sleep wake-up via GPIO after: 0.000995 secs clock. 0.000244 secs CPU. |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
545浏览 6评论
457浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
438浏览 5评论
441浏览 4评论
411浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 13:16 , Processed in 0.665871 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号