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

1 ACCEPTED SOLUTION

Accepted Solutions
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-

View solution in original post

13 REPLIES 13
Zt Liu
Senior III
Posted on June 09, 2017 at 16:57

How would you like to wake up the MCU?

Which IRQ did you disable? Did you disable SysTick interrupt?

Are you still debugging the MCU while it is trying to enter stop mode?

Posted on June 10, 2017 at 09:38

I have disabled all IRQ (I believe there are 32 of them). I have tried both debug and release build but the problem persists. Once I figure out how to put the processor into stop mode I'd like to wake it up by GPIO EXTI.

Posted on June 10, 2017 at 12:11

Can't see why the above code can't work! 

Currently I got no other L0 series except for STM32L011 Nucleo 32 board.

I tried your code, even though you didn't set up external int source and you didn't turn off other gpio for power saving....

It just worked, I just add an external int source to make it wake up.

Guess there is something wrong in your code that it's not seen here.

   /*your code below*/

__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); 

HAL_PWREx_EnableUltraLowPower(); 

HAL_PWREx_EnableFastWakeUp(); 

__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI);

   /*Just add an external int source, firstly jumper on D2 and ground then take off jumper to wake up mcu*/

GPIO_InitTypeDef GPIO_InitStruct;

GPIO_InitStruct.Pin = GPIO_PIN_12;

GPIO_InitStruct.Pull = GPIO_PULLUP;

GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;

__HAL_RCC_GPIOA_CLK_ENABLE();

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/* Enable and set PA.12 EXTI Interrupt*/

NVIC_SetPriority((IRQn_Type)(EXTI4_15_IRQn), 0x03);

HAL_NVIC_EnableIRQ((IRQn_Type)(EXTI4_15_IRQn));

HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

 /*Wake up starts here*/

SystemClock_Config();

/*Config LED and flash it*/

BSP_LED_Init(LED3);

BSP_LED_On(LED3);

HAL_Delay(500);

BSP_LED_Off(LED3);

HAL_Delay(500)

BSP_LED_On(LED3);

HAL_Delay(500);

BSP_LED_Off(LED3);

HAL_Delay(500)

Posted on June 12, 2017 at 11:11

Your code does not work for me as well. The strangest thing is that it does not work just after I burn the program into the FLASH. If I unplug the power and plug it back in, it suddenly works (every time. From this point on it does not matter if I restart the device 100 times, it works every time).

1.So I burn the program into the chip

2.LED keeps blinking (stop mode not working)

3.I unplug the power and plug it back in

4.LED blinks once and blinks again every time I press the button (stop mode working)

Note that if I reset the device with NRST pin it won't work. I have to turn off the power.

Posted on June 12, 2017 at 11:48

Are you using a custom board?

Have you seen the PWR examples in STM32L0 Cube sdk?

Posted on June 12, 2017 at 13:00

Yes, I am using a custom board. I am also aware of the L0 examples. I have based my 'go to sleep process' on a L053 'PWR_STOP' example.

Nesrine M_O
Lead II
Posted on June 12, 2017 at 17:02

Hi

DUBOVSKY.MICHAL

I am using a custom board.

Have a look to the getting started hardware of your STM32 related product you find some Recommended PCB routing guidelines:

http://www.st.com/content/ccc/resource/technical/document/application_note/fd/f4/6b/40/9a/b5/41/a2/DM00112pdf/files/DM00112pdf/jcr:content/translations/en.DM00112pdf

-Nesrine-

Posted on June 12, 2017 at 18:18

Thank you, unfortunately the same thing happens to me when I use STM32L053R8 nucleo board.

Michal Dubovsky
Associate II
Posted on June 13, 2017 at 09:08

UPDATE:

(Note: This happens only after the first startup. If I power the device down and back up, evetything works)

1.Program executes 

HAL_PWR_EnterSTOPMode();

2.The processor does not go to STOPMode and goes straight to another function which is 

SystemClock_Config();

3.I get HAL_TIMEOUT @ stm32l0xx_hal_rcc.c line 695

while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSI48RDY) == RESET)

{

   if((HAL_GetTick() - tickstart) > HSI48_TIMEOUT_VALUE)

   {

      return HAL_TIMEOUT;

   }

}

Attaching my clock configuration below (supply voltage 2.2V):

0690X00000607JiQAI.png