Page 2 of 3

Re: Reset reason

Posted: Tue Jan 17, 2017 6:03 pm
by Tabulous
yeah the RCC->CSR Reg has about 6 bits for reset reasons, but if cleared by RMVF bit on startup, the next reset should have the correct reason for reset.

Re: Reset reason

Posted: Tue Jan 17, 2017 7:11 pm
by Giovanni
Is it guaranteed that you find only one bit raised? Couldn't find this info.

Giovanni

Re: Reset reason

Posted: Wed Jan 18, 2017 9:48 am
by neums
I've asked it there:

https://community.st.com/thread/35979-r ... on-stm32fx

waiting for response...

Re: Reset reason

Posted: Wed Jan 18, 2017 5:08 pm
by neums
Hi,
ST answered:
"It's possible in case of internal reset to have 2 Flag set in the same time."

Re: Reset reason

Posted: Wed Jan 18, 2017 5:11 pm
by Giovanni
So this API could just report "external reset" or "other reset" and a mask of platform-dependent flags, the RCC_CSR register in the STM32 case.

Giovanni

Re: Reset reason

Posted: Wed Jan 18, 2017 5:36 pm
by neums
May we wait for other replies at STMs page for some days.

Re: Reset reason

Posted: Mon Mar 13, 2017 4:18 pm
by Tabulous
if you poll the CRS register in this order, you will know you reason for reset. Yes NRST is always set as every reset work by pulling NRST low for afew micro seconds, but it should be the last bit you poll.

Code: Select all

    if( RCC->CSR & ( 1 << 31 ))
    {
        TGL_DEBUG( DBG_MASK_APP, "$ APP - RESET(PLWR)\r\n" );
    }
    else if( RCC->CSR & ( 1 << 30 ))
    {
        TGL_DEBUG( DBG_MASK_APP, "$ APP - RESET(WWDG)\r\n" );
    }
    else if( RCC->CSR & ( 1 << 29 ))
    {
        TGL_DEBUG( DBG_MASK_APP, "$ APP - RESET(IWDG)\r\n" );
    }
    else if( RCC->CSR & ( 1 << 28 ))
    {
        TGL_DEBUG( DBG_MASK_APP, "$ APP - RESET(SOFT)\r\n" );
    }
    else if( RCC->CSR & ( 1 << 27 ))
    {
        TGL_DEBUG( DBG_MASK_APP, "$ APP - RESET(POR)\r\n" );
    }
    else if( RCC->CSR & ( 1 << 26 ))
    {
        TGL_DEBUG( DBG_MASK_APP, "$ APP - RESET(NRST)\r\n" );
    }



Tested this and seems to work.

Re: Reset reason

Posted: Sat Dec 02, 2017 8:39 pm
by Giovanni
Moving topic.

Giovanni

Re: Reset reason

Posted: Sun Jan 06, 2019 5:02 pm
by Giovanni
bump

It will go in next HAL in a specific driver.

Re: Reset reason

Posted: Wed May 15, 2019 10:27 pm
by electronic_eel
Is there already any HAL code for this available that I could test?

I'm just working on a project where I need to check if the watchdog triggered a reset and alert the user that something went wrong.

Thanks.