2021-05-12 06:39 PM
If you run it with the reset pin, you can use the "__HAL_RCC_GET_FLAG()" function
You can see that "RCC_FLAG_PINRST" is set.
However, when executed with "HAL_NVIC_SystemReset()", "RCC_FLAG_SFTRST" and "RCC_FLAG_PINRST" are set.
My expectation is that only "RCC_FLAG_SFTRST" should be set.
what is the reason?
And "__HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST)" doesn't work at all.
//my code
void main()
{
if(true == __HAL_PWR_GET_FLAG(PWR_FLAG_WUF2))
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2);
debug("wakeup pin 2\r\n");
}
if(true == __HAL_PWR_GET_FLAG(PWR_FLAG_SB))
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
debug("Standby\r\n");
}
if(true == __HAL_PWR_GET_FLAG(PWR_FLAG_WUF))
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF);
debug("all wakeup pin\r\n");
}
if(true == __HAL_RCC_GET_FLAG(RCC_FLAG_PWRRST))
debug("POWER ON RESET\r\n");
if(true == __HAL_RCC_GET_FLAG(RCC_FLAG_PINRST))
debug("PIN RESET\r\n");
if(true == __HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST))
debug("SOFTWARE RESET\r\n");
if(true == __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST))
debug("WATCHDOG RESET\r\n");
if(true == __HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST))
debug("LOWPOWER RESET\r\n");
__HAL_RCC_CLEAR_RESET_FLAGS();
while(1)
{
if(GPIO_PIN_RESET == HAL_GPIO_ReadPin(BTN1_GPIO_Port,BTN1_Pin))
{
HAL_NVIC_SystemReset();
}
if(GPIO_PIN_RESET == HAL_GPIO_ReadPin(BTN2_GPIO_Port,BTN2_Pin))
{
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_HIGH);
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 9, RTC_WAKEUPCLOCK_CK_SPRE_16BITS);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF2|PWR_FLAG_SB);
HAL_PWR_EnterSTANDBYMode();
}
}
}
Solved! Go to Solution.
2021-05-12 08:04 PM
That's just how it works. PINRSTF is set on most types of reset. Examine all flags and match up to the expected pattern for the given reset type.
2021-05-12 08:04 PM
That's just how it works. PINRSTF is set on most types of reset. Examine all flags and match up to the expected pattern for the given reset type.
2021-05-12 08:45 PM
thank you. Resolved.
What kind of document is the screenshot?
2021-05-12 09:01 PM