STM32U585 - Wakeup reason detection when exiting shutdown
Hi,
Im trying to get WUP reason after the MCU exited the shutdown. I'm using pushbutton connected to PC5 pin to wake up the MCU. I cannot get the WUP flag to behave correctly. Sometimes it is present, sometimes not. This feature is part of bigger project where I use WUP by two alarms and pushbutton. I have no problem detecting that the WUP happend due to alarmA or alarmB, but I'm struggling with the pushbutton.
Here is code snippet from test app where I am debugging behaviour of WUP:
__HAL_RCC_GPIOC_CLK_ENABLE();
HAL_UART_Transmit(&hlpuart1, "Hello\r\n", 7, 300);
if(PWR->WUSR & PWR_WUSR_WUF5)
{
PWR->WUSCR &= PWR_WUSCR_CWUF5; //clear flag
HAL_UART_Transmit(&hlpuart1, "Button WUP!\r\n", 13, 300);
}
char buff[32]="";
sprintf(buff, "WUSR:%08X, CSR:%08X\r\n",PWR->WUSR,RCC->CSR);
HAL_UART_Transmit(&hlpuart1, buff, strlen(buff), 300);
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN5);
__HAL_PWR_CLEAR_FLAG(PWR_WAKEUP_FLAG5);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN5_HIGH_0);
HAL_PWREx_EnterSHUTDOWNMode();If I attach the debugger everything starts to work just fine. Is there something I am doing wrong ? Are the registers reseted upon exiting shutdown ?
