light sleep模式下定时呼醒和外部中断呼醒不能同时使用问题

dodo55
Posts: 41
Joined: Fri Nov 19, 2021 10:01 am

light sleep模式下定时呼醒和外部中断呼醒不能同时使用问题

Postby dodo55 » Wed Dec 08, 2021 3:01 am

芯片:ESP32
IDF:V4.3
例程:light_sleep_example_main.c
其中例程中设置定时呼醒时间大于3秒才凸显 问题,如:

Code: Select all

esp_sleep_enable_timer_wakeup(5000000);
项目中使用G-sensor,而G-sensor的中断脚输出连接至EPS32的GPIO17,
如果G-sensor中断输出配置成空闲高电平,中断输出时为低电平,然后ESP32配置为GPIO17低电平呼醒,此时定时呼醒和外部中断呼醒可以同时正常使用;
如果G-sensor中断输出配置成空闲低电平,中断输出时为高电平,然后ESP32配置为GPIO17高电平呼醒,此时定时呼醒和外部中断呼醒不可以同时正常使用,表现现象为GPIO17没有中断,但wakeup_reason = "pin",而且呼醒时间小于设定的定时呼醒时间(设置呼醒时间必须大于3秒才有效果);

请问,这是什么原因引起的?如何解决?

dodo55
Posts: 41
Joined: Fri Nov 19, 2021 10:01 am

Re: light sleep模式下定时呼醒和外部中断呼醒不能同时使用问题

Postby dodo55 » Sat Dec 11, 2021 6:42 am

dodo55 wrote:
Wed Dec 08, 2021 3:01 am
芯片:ESP32
IDF:V4.3
例程:light_sleep_example_main.c
其中例程中设置定时呼醒时间大于3秒才凸显 问题,如:

Code: Select all

esp_sleep_enable_timer_wakeup(5000000);
项目中使用G-sensor,而G-sensor的中断脚输出连接至EPS32的GPIO17,
如果G-sensor中断输出配置成空闲高电平,中断输出时为低电平,然后ESP32配置为GPIO17低电平呼醒,此时定时呼醒和外部中断呼醒可以同时正常使用;
如果G-sensor中断输出配置成空闲低电平,中断输出时为高电平,然后ESP32配置为GPIO17高电平呼醒,此时定时呼醒和外部中断呼醒不可以同时正常使用,表现现象为GPIO17没有中断,但wakeup_reason = "pin",而且呼醒时间小于设定的定时呼醒时间(设置呼醒时间必须大于3秒才有效果);

请问,这是什么原因引起的?如何解决?
现在还出现另外不好的现象,同时启用定时呼醒和GPIO呼醒时,我的项目同时使能了3个GPIO(分别GPIO0,GPIO5,GPIO17)来呼醒,而其中使用GPIO17很难呼醒,而使用GPIO0和GPIO5就读能呼醒灵敏,3个GPIO的配置都是输入模式,呼醒方式为低电平。
如果是在进入休眠2秒钟内呼醒,GPIO17能呼醒的成功率就比较高。
这都啥问题哦,咋个解决啊?

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

Re: light sleep模式下定时呼醒和外部中断呼醒不能同时使用问题

Postby ESP_ICY » Mon Dec 13, 2021 12:09 pm

1.首先确定一下你这边使用的唤醒方式,是 GPIO 电平唤醒还是 GPIO 中断唤醒,就是你使用的唤醒方式是esp_sleep_enable_gpio_wakeup 还是 esp_sleep_enable_ext0_wakeup ,根据你的描述,你提到 “表现现象为GPIO17没有中断”,所以是否想使用中断唤醒,但是 “wakeup_reason = "pin"” 这个在 example 中应该是使用了 GPIO 电平唤醒的。
2.可以尝试着在menuconfig → Component config → FreeRTOS中修改Tick rate (Hz)为1000

dodo55
Posts: 41
Joined: Fri Nov 19, 2021 10:01 am

Re: light sleep模式下定时呼醒和外部中断呼醒不能同时使用问题

Postby dodo55 » Tue Dec 14, 2021 8:20 am

ESP_ICY wrote:
Mon Dec 13, 2021 12:09 pm
1.首先确定一下你这边使用的唤醒方式,是 GPIO 电平唤醒还是 GPIO 中断唤醒,就是你使用的唤醒方式是esp_sleep_enable_gpio_wakeup 还是 esp_sleep_enable_ext0_wakeup ,根据你的描述,你提到 “表现现象为GPIO17没有中断”,所以是否想使用中断唤醒,但是 “wakeup_reason = "pin"” 这个在 example 中应该是使用了 GPIO 电平唤醒的。
2.可以尝试着在menuconfig → Component config → FreeRTOS中修改Tick rate (Hz)为1000
我前面已经提到
芯片:ESP32
IDF:V4.3
例程:light_sleep_example_main.c
然后我把

Code: Select all

#define BUTTON_GPIO_NUM_DEFAULT     0
改成

Code: Select all

#define BUTTON_GPIO_NUM_DEFAULT     17

Code: Select all

#define BUTTON_WAKEUP_LEVEL_DEFAULT     0
改成

Code: Select all

#define BUTTON_WAKEUP_LEVEL_DEFAULT     1

Code: Select all

esp_sleep_enable_timer_wakeup(2000000);
改成

Code: Select all

esp_sleep_enable_timer_wakeup(10000000);
然后我的GPIO17一直为低电平,但是呼醒的reason为pin,调试如下

Code: Select all

Entering light sleep
Returned from light sleep, reason: pin, t=192621 ms, slept for 1623 ms
Entering light sleep
Returned from light sleep, reason: pin, t=194231 ms, slept for 1601 ms
Entering light sleep
Returned from light sleep, reason: pin, t=195836 ms, slept for 1597 ms
Entering light sleep
Returned from light sleep, reason: pin, t=197427 ms, slept for 1582 ms
Entering light sleep
Returned from light sleep, reason: pin, t=199001 ms, slept for 1565 ms
Entering light sleep
Returned from light sleep, reason: pin, t=200602 ms, slept for 1593 ms
Entering light sleep
Returned from light sleep, reason: pin, t=202194 ms, slept for 1583 ms
Entering light sleep
Returned from light sleep, reason: pin, t=203759 ms, slept for 1557 ms
Entering light sleep
Returned from light sleep, reason: pin, t=205353 ms, slept for 1585 ms
Entering light sleep
Returned from light sleep, reason: pin, t=206928 ms, slept for 1566 ms
Entering light sleep
Returned from light sleep, reason: pin, t=208559 ms, slept for 1622 ms
Entering light sleep
Returned from light sleep, reason: pin, t=210176 ms, slept for 1608 ms
Entering light sleep
Returned from light sleep, reason: pin, t=211766 ms, slept for 1581 ms
Entering light sleep
Returned from light sleep, reason: pin, t=213374 ms, slept for 1600 ms
Entering light sleep
Returned from light sleep, reason: pin, t=214991 ms, slept for 1607 ms
Entering light sleep
Returned from light sleep, reason: pin, t=216578 ms, slept for 1579 ms
Entering light sleep
Returned from light sleep, reason: pin, t=218185 ms, slept for 1598 ms
Entering light sleep

dodo55
Posts: 41
Joined: Fri Nov 19, 2021 10:01 am

Re: light sleep模式下定时呼醒和外部中断呼醒不能同时使用问题

Postby dodo55 » Tue Dec 14, 2021 8:35 am

ESP_ICY wrote:
Mon Dec 13, 2021 12:09 pm
1.首先确定一下你这边使用的唤醒方式,是 GPIO 电平唤醒还是 GPIO 中断唤醒,就是你使用的唤醒方式是esp_sleep_enable_gpio_wakeup 还是 esp_sleep_enable_ext0_wakeup ,根据你的描述,你提到 “表现现象为GPIO17没有中断”,所以是否想使用中断唤醒,但是 “wakeup_reason = "pin"” 这个在 example 中应该是使用了 GPIO 电平唤醒的。
2.可以尝试着在menuconfig → Component config → FreeRTOS中修改Tick rate (Hz)为1000
我看了esp_sleep_enable_ext0_wakeup这个函数的注析

Code: Select all

/**
 * @brief Enable wakeup using a pin
 *
 * This function uses external wakeup feature of RTC_IO peripheral.
 * It will work only if RTC peripherals are kept on during sleep.
 *
 * This feature can monitor any pin which is an RTC IO. Once the pin transitions
 * into the state given by level argument, the chip will be woken up.
 *
 * @note This function does not modify pin configuration. The pin is
 *       configured in esp_sleep_start, immediately before entering sleep mode.
 *
 * @note In revisions 0 and 1 of the ESP32, ext0 wakeup source
 *       can not be used together with touch or ULP wakeup sources.
 *
 * @param gpio_num  GPIO number used as wakeup source. Only GPIOs which are have RTC
 *             functionality can be used: 0,2,4,12-15,25-27,32-39.
 * @param level  input level which will trigger wakeup (0=low, 1=high)
 * @return
 *      - ESP_OK on success
 *      - ESP_ERR_INVALID_ARG if the selected GPIO is not an RTC GPIO,
 *        or the mode is invalid
 *      - ESP_ERR_INVALID_STATE if wakeup triggers conflict
 */
esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level);
说是只针对RTC_IO的,而GPIO17不在其中,所以使用了此函数也没有作用。

Who is online

Users browsing this forum: virgil and 88 guests