STM32 wakeup from STOP2 mode using exernal interrupt(STMCUBE)

roopeshp wrote on Friday, May 17, 2019:

I am using freertos along with STMcube. configured tickless idle mode.
I have a task that polls a GPIO (PA0) , and goes to stop2 mode using the API HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);

When there is an interrupt on the same Pin (external interrupt wake u p pin), can I expect the system to wake up and resume all the tasks?

rtel wrote on Friday, May 17, 2019:

That depends on what stop mode turns off - if it keeps the clock used by
the tickless idle mode running, and keeps the RAM and register contents,
then the answer is probably yes. There are many different variations of
low power mode though so it is very specific to your chip and the low
power mode chosen.

richarddamon wrote on Friday, May 17, 2019:

STM32 Stop2 mode (at least on the procssors I have looked at) stops the processor clock, and many of the peripheral. Certain specified peripheral (most some Low Power peripheral) still run and can wake the system. I haven’t looked at this in detail, but likely will need to do this in the future, but I suspect that you will need some code to fully restore the system environment (the system wakes up in a reduced operating state as I remember), and after doing that you should be able to reenable interrupts and the system should resume.

Since the system clock stopped, if you use the default systick driver, the system has no idea how long it was in the ‘Stop 2’ mode so be prepared for that. If you use a low power timer, running off a clock that is kept on during the Stop 2 Mode, you may be able to tell FreeRTOS how long it was asleep.

roopeshp wrote on Monday, May 20, 2019:

Thank you Richard.
I am thinking of calling the follwing after interrup wake up
/* Reset of all peripherals, Initializes the Flash interface and the Systick. /
Configure the system clock /
Initialize all configured peripherals */

/* Call init function for freertos objects (in freertos.c) */

/* Start scheduler */

or what is the best way to do this? these are beng called in the main. can I set my program conter to start from main (inside the ISR)?