I have STM32WLE5 series and I am trying to wake it up using hardware WKUP pin from STOP mode. That pin (PC13 = Wake-up 1 = PWR_WKUP2) is connected to my external button (automatically pulled down, button pulls it up).
After wakeup I read logic level of that pin and "reinit" it like CubeMX did:
GPIO_InitTypeDef GPIO_InitStructCOn = {0};
GPIO_InitTypeDef GPIO_InitStructCOff = {0};
GPIO_InitStructCOn.Pin = GPIO_PIN_13;
GPIO_InitStructCOn.Mode = GPIO_MODE_INPUT;
GPIO_InitStructCOn.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructCOn);
uint8_t caseOpen = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13);
GPIO_InitStructCOff.Pin = GPIO_PIN_14|GPIO_PIN_15;
GPIO_InitStructCOff.Mode = GPIO_MODE_ANALOG;
GPIO_InitStructCOff.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStructCOff);
Before entering STOP mode I do this to setup the pin (the pin is called 1 and 2 at once and I am unsure, what is correct, hence I enable both of them):
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2);
I enter stop mode with WFE like this (so everything can wake it up):
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFE);
Reading it using INPUT mode works fine, so it is not hardware error. The power consumption is important to me, hence I do not use software EXTI.
Anybody knows, what I am doing wrong? I am also using RTC for auto wakeup and it works fine.