cancel
Showing results for 
Search instead for 
Did you mean: 

Shutdown mode problem with STM32L4

jonathan239955_stm1_st
Associate II
Posted on April 10, 2017 at 09:56

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

10 REPLIES 10
Nesrine M_O
Lead II
Posted on April 10, 2017 at 10:42

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

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/93/81/9b/8d/2f/09/4a/e8/DM00125306/files/DM00125pdf/jcr:content/translations/en.DM00125pdf

  • also refer 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-

Posted on April 10, 2017 at 11:19

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;

         }

      }

}

Posted on January 02, 2018 at 12:25

Hi Constant,

I have the same problem. Have you foud a solution?

Marco

DIJITH PADINJARAYIL
Associate II
Posted on January 04, 2018 at 07:21

hi i too have same issue any body found solution ,please help me

Posted on January 04, 2018 at 09:21

HI Dijith,

I partially solved the problem adding HAL_PWREx_DisableInternalWakeUpLine() just before HAL_PWREx_EnterSHUTDOWNMode();

It seems working on my setup.

Marco

Posted on January 04, 2018 at 09:28

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

Posted on January 04, 2018 at 12:52

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?

Posted on January 05, 2018 at 08:52

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

Overnature
Associate II

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