2017-06-09 07:29 AM
Hello, I am running into a problem while trying to put MCU into a STOP mode. I have tried to comment out all of the 'unnecessary' code but It does not work even if I leave just this in the source:
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
while(1)
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); // clear WU FLAG
HAL_PWREx_EnableUltraLowPower(); // Enable Ultra low power mode HAL_PWREx_EnableFastWakeUp(); // Enable the fast wake up from Ultra low power mode // Select HSI as system clock source after Wake Up from Stop mode __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI); // go to sleep with low power regulator ON // WFI = the device is woken up by any pending interrupt HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);blink_led();
}
It seems as if the processor never even entered the sleep mode (or woke up immediately after entering it) because the LED just keeps blinking. This happens even if I disable all interrupt sources using HAL_NVIC_DisableIRQ();
Solved! Go to Solution.
2017-06-13 03:52 AM
Hi
Try to disable the
Systick interrupt
/* Enter Stop Mode */HAL_SuspendTick();HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);HAL_ResumeTick();�?�?�?�?
-Nesrine-
2017-06-13 04:18 AM
This totally works. I can't find a reason why this isn't mentioned in the example or in a HAL_PWR_EnterSTOPMode() function description.
2017-06-13 04:31 AM
How would you like to wake up the MCU?
Which IRQ did you disable? Did you disable SysTick interrupt?
But I have already asked this!!
You said you turned off all IRQ?!?!
:((
2017-06-13 05:24 AM
Yes, you are totally right. I missed all the IRQ's on a negative side of the enum. So I made a cycle which disabled IRQ 0 through 31 but not -14,-13,-5,-2 and -1.