cancel
Showing results for 
Search instead for 
Did you mean: 

How do I find out, that the battery was inserted into my system? = find out the difference between power up and reset after shutdown/standby mode ( G031 )

SThie.1
Associate II

We have a battery driven system based on STM32G031K8 and a S2-LP for RF running from a CR2032.

I use the shutdown mode to keep power as low as possible. System is done by a reed contact connected to a wake up pin.

We want to find out, whether the battery was entered, or the system reset was caused by exiting the shutdown mode.

Further on, we use the standby mode and we want to know when the reset occurs, whether it was caused by exiting the shutdown mode or by exiting the standby mode.

As both modes do a reset on exiting, I see no difference at the moment.

Any ideas?

Furthermore, when the battery is getting low, the processor does some resets, when the battery voltage drops below 1.7V and after some time, the battery recovers a little bit.

Any ideas how to find out the difference betweeen that. Hence the battery voltage is not a good indicator, I already tried that.

1 ACCEPTED SOLUTION

Accepted Solutions
SThie.1
Associate II

Hi Sarra, thanks for the hints. I was able to apply some of them, however find out difference between leaving standby/shutdown did not work for me, as both performing a reset, deleting my flag.

I placed the flag in the 20 bytes option Ram, that was working, as this is deleted on power loss, but not touched by reset.

best regards

View solution in original post

3 REPLIES 3
Sarra.S
ST Employee

Hello @Community member​,

To distinguish between system reset caused by shutdown/ standby or by the battery, you can try monitoring the standby flag SBF is SR1 register, this bit is cleared by a power-on reset and it is not cleared by the system reset.

To distinguish between a reset caused by exiting shutdown or by standby, you could use a similar approach, you could set a flag to indicate that the system is entering the standby mode. When the system wakes up from the reed contact, you can check this flag to determine whether the reset was caused by exiting standby or shutdown.

If the flag is set, it means that the reset was caused by exiting the standby mode, otherwise it was caused by exiting shutdown.

Hope that helps!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

SThie.1
Associate II

Hi Sarra, thanks for the hints. I was able to apply some of them, however find out difference between leaving standby/shutdown did not work for me, as both performing a reset, deleting my flag.

I placed the flag in the 20 bytes option Ram, that was working, as this is deleted on power loss, but not touched by reset.

best regards

Piranha
Chief II

The reset reasons are indicated in the RCC_CSR register. In particular the POR/BOR events are indicated by the PWRRSTF bit.

https://community.st.com/s/question/0D53W00001bnh8dSAA/how-to-enter-standby-or-shutdown-mode-on-stm32