cancel
Showing results for 
Search instead for 
Did you mean: 

unwanted stop mode wakeup (STM32L052K8)

Michal Dubovsky
Associate II
Posted on June 09, 2017 at 16:29

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();

13 REPLIES 13
Posted on June 13, 2017 at 10:52

Hi

Try to disable the

Systick interrupt

/* Enter Stop Mode */HAL_SuspendTick();HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);HAL_ResumeTick();�?�?�?�?

-Nesrine-

Posted on June 13, 2017 at 11:18

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.

Posted on June 13, 2017 at 11:31

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?!?! 

:((

Posted on June 13, 2017 at 12:24

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.