Skip to main content
ckim.2390
Associate II
May 13, 2021 1:39 AM UTC
Solved

Why pinrst is configured after sftrst

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();

  }

}

}

This topic has been closed for replies.
TDK
TDKBest answer
May 13, 2021 3:04 AM UTC

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.

0693W00000AOClqQAH.png

"If you feel a post has answered your question, please click ""Accept as Solution""."

3 replies

TDK
TDKBest answer
May 13, 2021 3:04 AM UTC

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.

0693W00000AOClqQAH.png

"If you feel a post has answered your question, please click ""Accept as Solution""."
ckim.2390
ckim.2390Author
Associate II
May 13, 2021 3:45 AM UTC

thank you. Resolved.

What kind of document is the screenshot?

TDK
May 13, 2021 4:01 AM UTC
That’s in the stm32h7 reference manual.
"If you feel a post has answered your question, please click ""Accept as Solution""."