How to reading wakeup flag?
I want to know which Wakeup pin or Reset pin wakes up the microprocessor that enters standby mode. I have 2 wakeup pins.
I am monitoring SR1 and SR2 variables with Live expression in Debug mode, but when I wake up from standby mode, the value of the variables does not change.
Is there a method other than the code block below?
I am grateful in advance.
/* USER CODE BEGIN 2 */
CheckWakeupPins();
/* USER CODE END 2 */
/* USER CODE BEGIN 4 */
void CheckWakeupPins(void) {
// Ensure the PWR clock is enabled
__HAL_RCC_PWR_CLK_ENABLE();
// Read the wakeup pin status from PWR_SR1
uint32_t wakeup_status = __HAL_PWR_GET_FLAG(PWR_FLAG_WU);
// Check individual wakeup pins - adjust mask as per your device's definitions
SR1 = (wakeup_status & PWR_FLAG_WUF1) ? 1 : 0;
SR2 = (wakeup_status & PWR_FLAG_WUF2) ? 1 : 0;
HAL_Delay(3000);
// Clear the wakeup flags after processing to avoid retriggering
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
}
/* USER CODE END 4 */
