Reset reason
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Reset reason
Is it guaranteed that you find only one bit raised? Couldn't find this info.
Giovanni
Giovanni
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Reset reason
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
Giovanni
Re: Reset reason
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.
Tested this and seems to work.
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.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
-
- Posts: 77
- Joined: Sat Mar 19, 2016 8:07 pm
- Been thanked: 17 times
Re: Reset reason
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.
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 41 guests