Resuming scheduler after restart

evgeny-erlihman wrote on Wednesday, December 06, 2017:

I am working with stm32h7 MCU, one of its features is BAM (batch acquisition mode). In this mode the MCU goes into a low power mode to gather data. To wake up from this mode, the MCU resets, but the clock configuration is not changed as well as the memory content. So theoretically, if there was a way to make the system continue runing from the same place it left of, which is PreSleepProcessing, the system state can be retained.
Is there a way to resume the FreRTOS scheduler instead of restarting it? Because all tasks and current state is still in the memory. And we know when we are about to reset, so we can save memory, regs etc before…

rtel wrote on Wednesday, December 06, 2017:

Sorry I don’t fully understand your question. If everything is still in
memory what is being reset? Is it just the program counter that gets
set back to the reset vector? If so you could potentially use the
pre-sleep configPRE_SLEEP_PROCESSING()
(https://www.freertos.org/low-power-ARM-cortex-rtos.html) macro to save
the state of the program counter too then have the reset code check to
see why the CPU was reset and take appropriate action on wake - but this
is not really something FreeRTOS can do for you.

evgeny-erlihman wrote on Thursday, December 07, 2017:

Sure, i figured out that i would have to save the call stack and PC before i put the system in low power mode, inside configPRE_SLEEP_PROCESSING, and restore it once i land in main() after reset. Was hoping that there is already an infrastructure inplace for this functionlality. Would try it out later, if ST hasn’t provided its costumers with the port by then…