EXTI only exits STOP Mode 2 the first time
Hello,
I have a test app that starts in wake for 5s (with "high" current and GPIO output high) then enters STOP Mode 2 (with "low" current and GPIO output low). It remains in that mode until the EXTI 1 interrupt is triggered by a button press, which wakes it up (current and output go high). That much works.
5s after waking up from the button press it then reenters STOP Mode 2. Pressing the button again does nothing. After seeing that, I added the code below to reinitialize the GPIO both in the EXTI callback function and just before calling HAL_PWREx_EnterSTOP2Mode() - neither one of those made it work. Note that the EXTI callback function calls SystemClock_Config() and HAL_ResumeTick() before the code below is called. Using the debugger, I can see that EXTI1_IRQHandler() does not get called after reentering STOP Mode 2.
What else could be missing? (If I press the button multiple times after the first press but before it reenters STOP I do see the IRQ trigger each time - it's only after it reenters STOP that it will no longer trigger.)
Thanks
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
EXTI->IMR1 |= GPIO_PIN_1;
HAL_NVIC_SetPriority(EXTI1_IRQn, 15, 0);
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
