cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F437 exiting standby incorrectly

georgeclarkson5
Associate II
Posted on November 02, 2015 at 10:56

Hi there,

I'm currently having some issues with the STM32F437 package going into standby, whenever I send the instruction to go into standby the device goes to sleep but then almost immediately wakes back up again. The code I'm using to send the device to standby is:

/*## Disable all wakeup sources #####################################*/
/* Disable Wake-up pin */
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
/* Disable RTC Alarm */
HAL_RTC_DeactivateAlarm(&hrtc, RTC_ALARM_A);
HAL_RTC_DeactivateAlarm(&hrtc, RTC_ALARM_B);
/*## Clear all related wakeup flags ######################################*/
/* Clear PWR wake up Flag */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
/* Clear the Alarm Flag */
__HAL_RTC_ALARM_CLEAR_FLAG(&hrtc, RTC_FLAG_ALRAF);
__HAL_RTC_ALARM_CLEAR_FLAG(&hrtc, RTC_FLAG_ALRBF);
/*## Re-enable all used wakeup sources ###################################*/
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
HAL_PWR_EnterSTANDBYMode();

Am I missing anything here? #pwr #standby
19 REPLIES 19
georgeclarkson5
Associate II
Posted on November 20, 2015 at 15:50

upon power up I've been running the following code the whole time,

PWR->CR |= PWR_CR_CWUF;
if
( __HAL_PWR_GET_FLAG( PWR_FLAG_SB ) != RESET ) {
/* System resumed from STANDBY mode */
__HAL_PWR_CLEAR_FLAG( PWR_FLAG_SB ); 
/* Clear StandBy flag */
__HAL_PWR_CLEAR_FLAG( PWR_FLAG_WU ); 
/* Clear Wakeup flag */
}

ftiti
Associate II
Posted on November 23, 2015 at 17:02

Deamonata, the routine that you descibe is not clear enough; please give a cleaner code descibing the PWR registers' bits that you modify./update before, inside and after the if{}

georgeclarkson5
Associate II
Posted on November 24, 2015 at 12:18

I'm not quite sure what information you are after when you say the code isn't clear enough. I'm not keen on posting too much code as this is a commercial product.

The code that I provided uses is pretty much entirely composed of HAL driver stuff. and it show that on power up I check if the standby flag is set (i.e. I've just woken up from a reset) and if so clears the flag and also the wakeup flag. which is what you had asked before ''Anyway, you should clear the standby flag (PWR_FLAG_SB) in addition to to all used wakeup sources' flags.''

with regards to the ''Is you code is entering and exiting standby mode more than one time ? '' It is indeed i have a 5 second timer which triggers a standby event at which point the 

code in my opening post is called and the device is sent to shut down.

Is there something specific you are looking for when you're asking for more code?

georgeclarkson5
Associate II
Posted on December 02, 2015 at 12:12

Does anyone have any more suggestions?

georgeclarkson5
Associate II
Posted on December 07, 2015 at 11:41

No one have any more ideas?

georgeclarkson5
Associate II
Posted on December 16, 2015 at 17:46

I'm still stuck with this problem

dthedens
Associate II
Posted on December 16, 2015 at 18:11

It is a commercial product, we understand.

you will have create a simple project that contains just the problem issue and then post that code.

Otherwise, no one can provide much help.
Posted on December 16, 2015 at 19:35

I'm still stuck with this problem

Have you discussed it with an ST FAE assigned to your account/locality? Perhaps they can recommend a consultant/contractor with experience in this area?

I'm not doing keyhole debugging of HAL code. Perhaps you can separate this from your ''commercial'' board/code base, and demonstrate the use case on other common hardware like a DISCO or EVAL board. Either prove it works there, and if it fails push that up the support chain.

You really can't debug STOP/STANDBY code with a debugger attached. You'll need to instrument your code sufficiently either via USARTs or LEDs/GPIOs to understand what's going on in your system.

I'd suggest you also try doing the test using an SPL or register level implementation, to prove it's not a HAL issue.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Walid FTITI_O
Senior II
Posted on January 12, 2016 at 13:19

Hi Deamonata, Hi All,

After reading all the posts from your side. your issue is coming from the fact that your code is confusing between the power-ON and the resuming from Standby mode.

So, you should proceed like the following:

/* Check and Clear the Wakeup flag if already set*/
if(__HAL_PWR_GET_FLAG(PWR_FLAG_WU) != RESET) 
{ 
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); 
} 
/* Check the status of standby flag SB*/
if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) == RESET) 
{ 
/* Power-ON routine */ 
- Clearing all flag 
- RTC configuration 
- Entering standby routine 
} 
else 
{ 
/*Resuming from standby routine */
……….. 
} 

You should also, make attention when you want to debug a low power mode, in this case you need to Enable the debug for that mode :

For standby mode debug:

/* Enable the Debug Module during STANDBY mode */ 
HAL_EnableDBGStandbyMode(); 

I recommend that you take a look to the application note AN4538 at this

http://www.st.com/web/en/resource/technical/document/application_note/DM001214pdf

:

Power consumption optimization with STM32F3xx microcontrollers “

Yo

u will be inspired from this ANwhere wehave developed a use case similar to your application where all the power modes are used and it containes a(Power-On /standby resume) switching routine. You find the firmware at this

http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743/LN1734/PF257872

.

-Hannibal-

Eich
Associate III
Posted on September 11, 2017 at 10:29

Hi !

Are you using the IWDG watchdog ?

If Yes you must uncheck the IWDG_STBY bit from the option bytes using the STLinkV2 utility.

Factory default is 'checked' which means the watchdog is running in standby mode an will reset your µC.

Another option is to leave it as it is an check at program start if there was a wakup from sleep mode and then check if the IWDG was the reason for it. If yes send it back to sleep. If not proceed with system start.

Dirk