I'm doing a very low power product where I'm saving the very last joule I can. In this case, I've done this:
- HP core is woken up very very very rarely (only for communicating)
- HP core deep sleep for a given amount of time and wake up the LP core
- LP core sets up two interrupt handler (one for monitoring a pin that's set when some external event occurs) and a timer (if the event doesn't occurs in time, it wakes up the HP core with an error set in the shared RTC memory)
- LP core enters "wait for interrupt" (wfi) state.
The documentation here state: (in ulp_lp_core_halt):
So I understood this as it was possible to program the LP core to wake up periodically. And the LP core would call ulp_lp_core_halt and it would be woken up anyway for the second period. I don't observe this. As soon as the LP core call halt, it's not woken up anymore.To stop the ULP from waking up, call ulp_lp_core_lp_timer_disable() before halting.
In the LP core code, for programming a timer, it's using the undocumented ulp_lp_core_lp_timer_set_wakeup_time which is, underneath, using this. For the gpio interrupt, it's using the undocumented ulp_lp_core_gpio_intr_enable.
All of this is working well, except for the large power consumption.
Since the microcontroller is only consuming 60µA in deep sleep while being able to wake up from a timer or a GPIO interrupt, I wonder if:
- Is it possible for the LP core to halt while (re)programming the deep sleep's wake up source ?
- If yes, then a function to do so would like be better than trying to deal with LP core internal's machinery. Since in most use case, using the LP core is for power reason, it seems dumb to waste power in WFI mode while a lower power domain exists doing the same thing ?
- If not, would it be possible to write a wakeup stub (which, on ESP32C6 is done by writing to the 10 ALWAYS ON REGISTERS, which are thus accessible to LP core) that only does that? The idea being to program the wakeup stub to one that's setting the new wakeup source for the LP core and wake up the HP core so it can set the wakeup source and reenter deep sleep immediately?
- Couldn't find how the deep sleep code is programming the wake up source. The only code I've found is no different than programming from the LP core. Yet, when I do this in the LP core and halt, it doesn't work, the LP core doesn't wake up again.