cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 Reset Issue

Mohit Aggarwal
Associate II

I have been facing a reset issue.

My controller resets randomly. I have Codded for the source of reset at the begin of the routine.

For the testing the code I made the system reset on purpose and was able to find flags set for BOR, Software reset, Internal watchdog timer, external PIN reset. so the logic works.

The issue i'am facing rite now is that the system gets resets randomly in about an hour or so(generic time..no specific pattern observed) and the only flag that is set is External PIN flag.

Now according to STM32 manuals it says External PIN flag will always be set if other source of reset is there and the block diagram shown clarifies it, and have observed to in my testing, every reset source is accompanied by External PIN flag set. and only External PIN flag is set when i purpose fully press the reset switch.

1) I want to ask the scenarios under which the External pin Flag can alone be set.

2) Which flag will be set in case the code crashes and the system restarts Automatically. (read on internet that system can crash because of stack,memory leaks, etc.. and cause reset.)

Any insight on the matter would be of great help.

3 REPLIES 3
Uwe Bonnes
Principal II

External Pin reset is always set, as even internal reset toggles NRST. In case external RST signal was not applied, decode the reset cause register, ignoring the external reset flag.

Hello Uwe,

Thanks for the prompt response.

As mentioned above

I,am decoding the reset cause registers too and have tested that they work when the particular kind of reset occurs.

1) I get BOR and PIN when system is powered on

2) I get Software rest and PIN when code is uploaded through debugger. or i intentionally but system reset command fro testing.

3) I get Internal watch dog timer and PIN when i intentionally make IWDT timeout.

4) I get only PIN reset when reset switch is pressed.

now the issue is..

I get Random PIN reset when my code is running. no switch is pressed. no other reset is shown with it.

My question is there any other source of reset too in which case ONLY PIN reset is set

My code checks for

1) RCC_FLAG_SFTRST

2) RCC_FLAG_BORRST

3) RCC_FLAG_PINRST

4) RCC_FLAG_IWDGRST

5) RCC_FLAG_OBLRST

6) RCC_FLAG_FWRST

7) RCC_FLAG_LPWRRST

😎 RCC_FLAG_WWDGRST

My code.

if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST)==1)

{

rf_sf=1;

}

if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST)==1)

{

rf_bor=1;

}

if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST)==1)

{

rf_pin=1;

}

if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)==1)

{

rf_iw=1;

}

if (__HAL_RCC_GET_FLAG(RCC_FLAG_OBLRST)==1)

{

rf_ob=1;

}

if (__HAL_RCC_GET_FLAG(RCC_FLAG_FWRST)==1)

{

rf_fw=1;

}

if (__HAL_RCC_GET_FLAG(RCC_FLAG_LPWRRST)==1)

{

rf_lp=1;

}

if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST)==1)

{

rf_ww=1;

}

Please let me know if there are any other source of reset that i,am missing to checkout on.

what flags are set in case of system crashes and then a reset occurs. this will help me in narrowing down if its a firmware issue of hardware issue.

Hope the situation is clearer now.

Stick a scope on NRST and have it trigger when it asserts.

Would review external circuits and things like watchdogs. ​Monitor stack depth, sanity check pointers, and instrument code so you can determine paths and commonality of failure.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..