title: How to setup the standby mode on a STM32F4 MCU running an RTOS and waking it up after?
body: <p>I like to put my STM32F412 into deep sleep mode and wake it after by pressing a button. This code should run together with an RTOS(Zephyr). So when executing the code, to put the device into deep sleep, other tasks etc. are active.</p>
  
  <p>So I am looking for a bullet proof approach, that makes it sure that the STM32F412 goes to standby and wakeup after.</p>
  
  <p>so far my (not working code):</p>
  
  <pre><code>#define POWER_WAKEUP_PIN LL_PWR_WAKEUP_PIN2
  
  // set PC0 as input gpio
  LL_GPIO_SetPinPull(GPIOC, LL_GPIO_PIN_0, LL_GPIO_PULL_NO);
  LL_GPIO_SetPinMode(GPIOC, LL_GPIO_PIN_0, LL_GPIO_MODE_INPUT);
  
  // activate EXTI line 0
  LL_EXTI_InitTypeDef EXTI_InitStruct = {0};
  
  LL_EXTI_DisableIT_0_31(LL_EXTI_LINE_ALL_0_31);
  
  EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_0;
  EXTI_InitStruct.LineCommand = ENABLE;
  EXTI_InitStruct.Mode = LL_EXTI_MODE_EVENT;
  EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING;
  LL_EXTI_Init(&amp;EXTI_InitStruct);
  
  // put to standby
  LL_PWR_DisableWakeUpPin(POWER_WAKEUP_PIN);
  LL_PWR_ClearFlag_WU();
  LL_PWR_EnableWakeUpPin(POWER_WAKEUP_PIN);
  
  LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY);
  LL_LPM_EnableDeepSleep();
  __WFI();
  </code></pre>
  
  <p>Its using the stm32 LL HAL. Any ideas what is missing</p>