2017-04-10 12:56 AM
Hello,
I have a board with the STM32L476RET6, the shutdown mode worked a time and now it resets just after the STM32 enters in shutdown mode. I tried the same program with another same board and the problem does not appear.
I thought it was a problem with an interrupt but even if I disable all interrupts, the problem persists. I also disabled RTC clock.
__disable_irq();
__disable_fault_irq(); HAL_PWREx_EnterSHUTDOWNMode();Thank you for your help,
Best Regards,
Jonathan
2017-04-10 01:42 AM
Hi
CONSTANT.Jonathan
,I tried the same program with another same board and the problem does not appear.
may be you have to verify your PCB, refer please to
SHUTDOWN example under the STM32L4 firmware package :
STM32Cube_FW_L4_V1.7.0\Projects\STM32L496ZG-Nucleo\Examples\PWR\PWR_SHUTDOWN ,this example shows how to enter the system in SHUTDOWN mode and wake-up from this mode using external RESET or WKUP pin.-Nesrine-
2017-04-10 04:19 AM
Hi Nesrine,
Thank you for your answer. I double-checked my PCB and all seems good. I used the shutdown example from STM32Cube for my project, I thnik the code is correct because it worked until now. I tried to disable all wakeup pins and I get the same problem: the system resets. Here is my code.
int main(void)
{ HAL_Init();powerState = OFF;
/* Enable Power Clock */
__HAL_RCC_PWR_CLK_ENABLE(); HAL_PWR_EnableBkUpAccess();while(1) {
loop();
}
void loop()
{ switch (powerState) { case OFF: {__disable_irq();
__disable_fault_irq();
/* Clear wake up Flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF3); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF4); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF5); HAL_PWREx_EnterSHUTDOWNMode();break;
}
}
}
2018-01-02 04:25 AM
Hi Constant,
I have the same problem. Have you foud a solution?
Marco
2018-01-03 10:21 PM
hi i too have same issue any body found solution ,please help me
2018-01-04 01:21 AM
HI Dijith,
I partially solved the problem adding HAL_PWREx_DisableInternalWakeUpLine() just before HAL_PWREx_EnterSHUTDOWNMode();
It seems working on my setup.
Marco
2018-01-04 01:28 AM
thank you,let me try now it self . next stage i need to use internal RTC alarm to wake up every 2 minutes .thanks for your support.please give me suggestion if u r free
2018-01-04 04:52 AM
hi marco,
see the code i used,
- Set NVIC Group Priority to 4
- Low Level Initialization */ HAL_Init();/* Configure the system clock to 80 MHz */
SystemClock_Config();/* Configure LED1 and LED3 */
BSP_LED_Init(LED2); // BSP_LED_Init(LED3);/* Enable Power Clock */
__HAL_RCC_PWR_CLK_ENABLE(); HAL_PWR_EnableBkUpAccess(); /* Check if the system was resumed from shutdown mode, resort to RTC back-up register RTC_BKP31R to verify whether or not shutdown entry flag was set by software before entering shutdown mode. */ if (READ_REG(RTC->BKP31R) == 1) { WRITE_REG( RTC->BKP31R, 0x0 ); /* reset back-up register */ out_of_shutdown = 1; /* out of shutdown detected */ }/* Insert 5 seconds delay */
HAL_Delay(5000); /* Disable all used wakeup sources: WKUP pin */ HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2); /* Clear wake up Flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2); /* Enable wakeup pin WKUP2 */ //HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_HIGH); /* Set RTC back-up register RTC_BKP31R to indicate later on that system has entered shutdown mode */ WRITE_REG( RTC->BKP31R, 0x1 ); __disable_irq();__disable_fault_irq();
/* Clear wake up Flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF3); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF4); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF5); HAL_PWREx_DisableInternalWakeUpLine(); /* Enter shutdown mode */ HAL_PWREx_EnterSHUTDOWNMode();can u check is thr anything wrong?
2018-01-05 12:52 AM
Hi Dijith,
actually your code looks correct. In my code I have also disabled the wakeup line. My code is for an STML4xx microcontroller, so the recovery from the shutdown can be managed by RTC or 5 GPIOs.
In my application recovery from the shutdown is given by PC13 so my complete shutdown code is this one:
HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_C, PWR_GPIO_BIT_13);
HAL_PWREx_EnablePullUpPullDownConfig();/* Disable used wakeup source: PWR_WAKEUP_PIN2 */
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2); HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN3); HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN4); HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN5);/* Clear all related wakeup flags */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2);/* Enable wakeup pin WKUP2 */
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_LOW);HAL_PWREx_DisableInternalWakeUpLine();
/* enter shutdown */
HAL_PWREx_EnterSHUTDOWNMode();
Let me know if this help you.
Marco
2019-02-12 07:29 AM
I have same problem on STM32L433RCI.
After entering shutdown mode microcontroller restarts every other time.
1 attempt: reset
2 attempt: stays in shutdown
3 attempt: reset
4 attempt: stays in shutdown
...
my code is
void enter_shutdown (void)
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_LOW);
HAL_PWREx_DisableInternalWakeUpLine();
HAL_PWREx_EnterSHUTDOWNMode();
}