简体   繁体   English

ESP32如何重置与PCNT一起使用的GPIO引脚,以便它们也可以用于从深度睡眠唤醒EXT1?

[英]ESP32 how to reset GPIO pins used with PCNT, so they can also be used for EXT1 wake up from deep sleep?

I configure 4 gpio pins as pulse counters to read Hall-effect liquid flow sensors, which works fine, but when I try to use those same pins to wake up from a deep sleep, sleep ends immediately. 我将4个gpio引脚配置为脉冲计数器,以读取霍尔效应液体流量传感器,效果很好,但是当我尝试使用这些相同的引脚从深度睡眠中唤醒时,睡眠立即结束。 If I don't configure the pins for PCNT, deep sleep works as expected. 如果我不配置PCNT的引脚,深度睡眠将按预期工作。

I even went so far as setting a flag in RTC memory so that it sleeps for as long as 5 seconds, wakes up and does not configure PCNT before trying to go back to sleep. 我什至在RTC内存中设置了一个标志,使它休眠长达5秒钟,醒来并且在尝试重新进入睡眠之前未配置PCNT。 It still wakes from the second sleep immediately, so whatever it is about those pins is retained across deep sleep. 它仍然会立即从第二次睡眠中唤醒,因此在深度睡眠过程中,关于这些引脚的任何信息都会保留下来。

Is there a way to restore the default state of those pins without resetting the entire device? 有没有一种方法可以恢复这些引脚的默认状态而无需重置整个器件?

The answer is, set both *_gpio_num members of pcnt_config_t to PCNT_PIN_NOT_USED and call pcnt_unit_config again: 答案是,将pcnt_config_t的两个* _gpio_num成员都设置为PCNT_PIN_NOT_USED并再次调用pcnt_unit_config:

pcnt_config_t pcnt_config = {
    .pulse_gpio_num = PCNT_PIN_NOT_USED,
    .ctrl_gpio_num = PCNT_PIN_NOT_USED,
    .channel = PCNT_CHANNEL_0;
}
pcnt_unit_config(&pcnt_config);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM