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-09 07:57 AM
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?
2017-06-10 02:38 AM
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.
2017-06-10 05:11 AM
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)
2017-06-12 04:11 AM
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.
2017-06-12 04:48 AM
Are you using a custom board?
Have you seen the PWR examples in STM32L0 Cube sdk?
2017-06-12 06:00 AM
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.
2017-06-12 08:02 AM
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:
-Nesrine-
2017-06-12 11:18 AM
Thank you, unfortunately the same thing happens to me when I use STM32L053R8 nucleo board.
2017-06-13 12:08 AM
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):