Reset reason

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Tabulous
Posts: 453
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 13 times

Re: Reset reason

Postby Tabulous » Tue Jan 17, 2017 6:03 pm

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.

User avatar
Giovanni
Site Admin
Posts: 12178
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 570 times
Been thanked: 487 times
Contact:

Re: Reset reason

Postby Giovanni » Tue Jan 17, 2017 7:11 pm

Is it guaranteed that you find only one bit raised? Couldn't find this info.

Giovanni

neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Location: Dresden, Germany
Has thanked: 10 times
Been thanked: 5 times

Re: Reset reason

Postby neums » Wed Jan 18, 2017 9:48 am

I've asked it there:

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

waiting for response...

neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Location: Dresden, Germany
Has thanked: 10 times
Been thanked: 5 times

Re: Reset reason

Postby neums » Wed Jan 18, 2017 5:08 pm

Hi,
ST answered:
"It's possible in case of internal reset to have 2 Flag set in the same time."

User avatar
Giovanni
Site Admin
Posts: 12178
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 570 times
Been thanked: 487 times
Contact:

Re: Reset reason

Postby Giovanni » Wed Jan 18, 2017 5:11 pm

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

neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Location: Dresden, Germany
Has thanked: 10 times
Been thanked: 5 times

Re: Reset reason

Postby neums » Wed Jan 18, 2017 5:36 pm

May we wait for other replies at STMs page for some days.

Tabulous
Posts: 453
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 13 times

Re: Reset reason

Postby Tabulous » Mon Mar 13, 2017 4:18 pm

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.

User avatar
Giovanni
Site Admin
Posts: 12178
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 570 times
Been thanked: 487 times
Contact:

Re: Reset reason

Postby Giovanni » Sat Dec 02, 2017 8:39 pm

Moving topic.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 12178
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 570 times
Been thanked: 487 times
Contact:

Re: Reset reason

Postby Giovanni » Sun Jan 06, 2019 5:02 pm

bump

It will go in next HAL in a specific driver.

electronic_eel
Posts: 37
Joined: Sat Mar 19, 2016 8:07 pm
Been thanked: 6 times

Re: Reset reason

Postby electronic_eel » Wed May 15, 2019 10:27 pm

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.


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 0 guests