cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5G9: wfi() instruction does not execute, no shutdown or standby

robintechnology4u
Associate

Hello,

I have a issue with my STM32U5G9. It does not go into standby or shutdown mode. I want to achieve a wake-up by the power button of my device. The powerbutton is connected to PWR_WKUP6 (pin PB5). The button has a 100k pull-up. I verified the voltage levels with a scope (3.3V --> 0V).

I checked with the examples in the STM32CubeU5 Github repo. This my code: 

void LowPower::EnterStandbyMode(void) {
    PrepareForLowPower();

    __disable_irq();
    for(int i = WWDG_IRQn; i <= JPEG_IRQn; i++) {
    	NVIC_ClearPendingIRQ((IRQn_Type)i);
    }

    /* Enable WakeUp Pin PWR_WAKEUP_PIN6 connected to PB.5 */
    HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN6_LOW_0);

    /* Clear all related wakeup flags*/
    __HAL_PWR_CLEAR_FLAG(PWR_WAKEUP_FLAG6);

    HAL_DBGMCU_DisableDBGStandbyMode();

    /* Enter the Standby mode */
    HAL_PWR_EnterSTANDBYMode();

    // If entry fails (e.g., if a debugger is attached), reset the system
    NVIC_SystemReset();
}

 I have a similar function for shutdown mode. I tried to clear all interrupt flags to make sure the WFI() instruction executes. I have the following code in my main.c:

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the System Power */
  SystemPower_Config();

  /* Configure the system clock */
  SystemClock_Config();

  /* Configure the peripherals common clocks */
  PeriphCommonClock_Config();

  /* USER CODE BEGIN SysInit */
  /* Uncomment to be able to debug after wake-up from Standby. Consuption will be increased */
  HAL_DBGMCU_EnableDBGStandbyMode();
  if (__HAL_PWR_GET_FLAG(PWR_FLAG_SBF) != RESET)
  {
	  /* Clear Standby flag */
	  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SBF);
	  /* Check and Clear the Wakeup flag */
	  if (__HAL_PWR_GET_FLAG(PWR_WAKEUP_FLAG6) != RESET)
	  {
		__HAL_PWR_CLEAR_FLAG(PWR_WAKEUP_FLAG6);
	  }
  }
  /* USER CODE END SysInit */

I call the LowPower::EnterStandbyMode() after a long press of my power button, but it just runs into the NVIC_SystemReset(), with or without debugger connected. To test this I tried to put a while(1) loop in the main if the SBF flag is set, but it just starts normal operation.

Is there anything which can block the WFI() instruction? I use the following peripherals: LTDC, GPU2D, DMA2D, USB, I2C, SAI,TIMER, ICACHE, DCACHE, CRC, ADC, DMA, OCTOSPI, RNG. The code runs on ThreadX / TouchGFX. My assumption is standby and shutdown mode stop peripheral clocks and there is no need to disable. Is my assumption correct? 

Or can ThreadX block the sleep / standby? 

Thanks in advance.

Robin 

0 REPLIES 0