Hi everyone,
I am working on a project using the ESP32-C6 (ESP-IDF 5.5.2) where I need to monitor a periodic 5 Hz rectangle signal (Active-Low) while the device is in Light Sleep (.light_sleep_enable = true).
The Issue:
In "Active Mode," everything works flawlessly using GPIO_INTR_NEGEDGE. However, I've observed that in Light Sleep, the hardware GPIO wakeup source is strictly level-triggered, not edge-triggered. Because my pulse duration is ~200ms, the system triggers, wakes up, but the pin stays LOW. This causes the CPU to re-trigger the wakeup immediately, creating an "interrupt storm" rather than detecting the specific edge transition.
My Current Configuration (sdkconfig.defaults):
# --- Flash Management ---
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
# Set base frequency to 80MHz and enable Power Management (DFS)
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=80
CONFIG_PM_ENABLE=y
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
# Completely disable and power down Wi-Fi, BT and PHY for max energy saving
CONFIG_BT_ENABLED=n
CONFIG_ESP_WIFI_ENABLED=n
CONFIG_ESP_PHY_ENABLE=n
Proposed Strategy:
To emulate edge-triggering, I am currently considering a "Toggle-Level-Wakeup" approach:
1. Initialize wakeup on GPIO_INTR_LOW_LEVEL.
2. Upon wakeup, the ISR switches the wakeup trigger to GPIO_INTR_HIGH_LEVEL before going back to sleep.
3. This way, the system only wakes up on the transition (edge) rather than staying awake while the pin is low.
My Questions:
1. Is this "Ping-Pong" level-toggling the standard practice for edge-emulation on ESP32-C6 in Light Sleep? Or is there a specific hardware feature or register bit I'm missing that allows true edge-detection in Light Sleep?
2. Regarding the handover after wakeup: When using the digital GPIO wakeup source, do I need to explicitly call rtc_gpio_deinit() to return the pin to the digital matrix, or is that strictly required only for EXT0/EXT1 RTC-IO wakeup sources?
3. Are there any known timing penalties or race conditions with this toggle method, especially if the pulse width were to decrease?
I’d appreciate any insights or "best practices" from others who have implemented low-frequency sensor monitoring on the C6 while keeping it in Light Sleep.
Thanks,
Karlheinz
Edge-Emulation for GPIO Wakeup in Light Sleep on ESP32-C6 – Is there a cleaner way?
-
MicroController
- Posts: 2661
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Edge-Emulation for GPIO Wakeup in Light Sleep on ESP32-C6 – Is there a cleaner way?
Maybe you can get the Pulse Count Controller (PCNT) to do what you want.I need to monitor a periodic 5 Hz rectangle signal (Active-Low) while the device is in Light Sleep (.light_sleep_enable = true).
Who is online
Users browsing this forum: Bytespider, ChatGPT-User, Google [Bot], meta-externalagent, Semrush [Bot] and 18 guests