How to put a FreeRTOS application in STOP2 mode (STM32L4)
In specific circunstances (power available, ...) I want to put the MCU in STOP2 mode. That decision is taken on a FreeRTOS task. I've tried some approaches but the MCU didn't stop at all. Is there any example available using FreeRTOS? The code I'm using (not working) is the following:
/* suspend scheduler*/
vTaskSuspendAll();
/* disables Interrupt requests, interrupts will still be able to wake up the system*/
__disable_irq();
__HAL_RCC_PWR_CLK_DISABLE();
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_SuspendTick();
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
HAL_ResumeTick();
/* System sleeps here*/
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
/* on wake up, restore system clock*/
HAL_RCC_DeInit();
SystemClock_Config();
/* check interrupts now*/
__enable_irq();
/*resume scheduler*/
xTaskResumeAll();Do you have any suggestion to change? In the final code I want it to be able to wake up when some pins change state, and also using the RTC, but for now I was only focused on the MCU stop.
Thanks in advance
Fernando
