cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot wakeup from STOP2 through EXTI

RWalko
Associate

Hello everyone,

I want to try to wakeup my system from the the STOP2 mode with a button press. The button is also in use in the rest of the application and works just fine. But when going to STOP2 it does not wake up the system again.

I've tried it with the preconfigured interrupt, which also handles the button presses while the system is active, as well as a change to an event based trigger setup right before going to STOP2. Both do not wake up the system.

 

void setEXTIEvent(void)
{
  LL_EXTI_InitTypeDef EXTI_InitStruct = {0};

  EXTI_InitStruct.LineCommand = ENABLE;
  EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_6;
  EXTI_InitStruct.Mode = LL_EXTI_MODE_EVENT;
  EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_FALLING;
  LL_EXTI_Init(&EXTI_InitStruct);
  HAL_NVIC_DisableIRQ(EXTI9_5_IRQn);
}

void setEXTIInt(void)
{
  LL_EXTI_InitTypeDef EXTI_InitStruct = {0};

  EXTI_InitStruct.LineCommand = ENABLE;
  EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_6;
  EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
  EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_FALLING;
  LL_EXTI_Init(&EXTI_InitStruct);
  NVIC_EnableIRQ(EXTI9_5_IRQn);
}

void EnterStop2Mode(void)
{
  SaveParamConfig();

  printf("Entering STOP2 mode...\n");
  setEXTIEvent();
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); 
  HAL_SuspendTick();
  HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFE);
  HAL_ResumeTick();

  setEXTIInt();
  MX_SUBGHZ_Init();

  printf("Woke up from STOP2\n");
}

 

 I've included the code for the current event based implementation. The interrupt based implementation just doesn't call the two setEXTI functions and PWR_STOPENTRY_WFI ist used instead. The general pin configuration is done through the code generator.

As the tag is not available I'm working on a STM32WLE5 MCU.

10 REPLIES 10

The STOPWUCK bit in the RCC_CFGR register seems to have been the right call. I set this bit at the start of the application and it seems to work fine now. Thanks a lot!

For people reading this, it seems if using an external crystal add this line at the beginning:

RCC->CFGR |= RCC_CFGR_STOPWUCK;