cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L431RCT6 wakes up immediately after standby

NEdom.1
Associate III

I am trying to use STM32L431RCT6 with STM32CubeIDE and STM32Cube_FW_L4_V1.18.1 for a low power mode application. I tried Sleep mode, Stop mode and they both work OK. But the standby mode does not working. The MCU wakes up instantly after entering standby mode. CubeMX setup is as below, using SYS_WKUP2 as wakeup pin.

 

NEdom1_1-1731950055328.png

My code for standby mode. The flags are cleared after wakeup using 

__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

 

  /* USER CODE BEGIN 2 */
  if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
  {
          __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);  // clear the flag

          /** display  the string **/
          char *str = "Wakeup from the STANDBY MODE\r\n";
          HAL_UART_Transmit(&huart2, (uint8_t *)str, strlen (str), HAL_MAX_DELAY);

          /** Blink the LED **/
          for (int i=0; i<20; i++)
          {
                  HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_4);
                  HAL_Delay(200);
          }

          /** Disable the WWAKEUP PIN **/
          HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2);  // disable PA0
  }
  /** Now enter the standby mode **/
   /* Clear the WU FLAG */
  if (RESET != __HAL_PWR_GET_FLAG(PWR_FLAG_WUF2)){
    /** display  the string **/
    char *str = "Wakup from PWR_FLAG_WUF2\r\n";
    HAL_UART_Transmit(&huart2, (uint8_t *)str, strlen (str), HAL_MAX_DELAY);
  }

  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2);
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

   /* clear the RTC Wake UP (WU) flag */
//  __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);

  /** display  the string **/
  char *str = "About to enter the STANDBY MODE\r\n";
  HAL_UART_Transmit(&huart2, (uint8_t *)str, strlen (str), HAL_MAX_DELAY);
  /** Blink the LED **/
  for (int i=0; i<5; i++)
  {
          HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_4);
          HAL_Delay(750);
  }

  /* one last string to be sure */
  char *str2 = "STANDBY MODE is ON\r\n";
  HAL_UART_Transmit(&huart2, (uint8_t *)str2, strlen (str2), HAL_MAX_DELAY);

  /* Enable the WAKEUP PIN */
  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2);

  /* Finally enter the standby mode */
  HAL_PWR_EnterSTANDBYMode();
  /* USER CODE END 2 */

 

The UART terminal receives text:

 

[01:18:06.402]收←◆STANDBY MODE is ON
Wakeup from the STANDBY MODE

[01:18:10.428]收←◆Wakup from PWR_FLAG_WUF2
About to enter the STANDBY MODE

[01:18:14.190]收←◆STANDBY MODE is ON
Wakeup from the STANDBY MODE

[01:18:18.216]收←◆Wakup from PWR_FLAG_WUF2
About to enter the STANDBY MODE

[01:18:21.979]收←◆STANDBY MODE is ON
Wakeup from the STANDBY MODE

[01:18:26.004]收←◆Wakup from PWR_FLAG_WUF2
About to enter the STANDBY MODE

 

I have tried STM32L031F6P6, it could enter standby mode and wake up by RTC. What happened with STM32L431RCT6? 

Thank you for your help!

3 REPLIES 3

Suspend the HAL Tick: HAL_SuspendTick() ?

Thanks Andrew.

The HAL_SuspendTick() and HAL_ResumeTick() are used with SLEEP Mode and STOP Mode functions and work well. In STANDBY Mode, it is like the MCU being Reset then start on with only RTC information and some backup registers preserved.

The same code works with STM32L031F6P6.

NEdom.1
Associate III

I reconfig the clock, the HSE and LSE. After generating the code and flashing, the standby mode is activated.

Try to change HSE and LSE back, or several compositions. Things goes normal.

Try to add back FreeRTOS. All is good.

Very strange STM32CubeIDE behavior. However, I like this IDE tool.