2015-11-02 01:56 AM
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
2015-11-20 06:50 AM
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 */
}
2015-11-23 08:02 AM
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{}
2015-11-24 03:18 AM
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?2015-12-02 03:12 AM
Does anyone have any more suggestions?
2015-12-07 02:41 AM
No one have any more ideas?
2015-12-16 08:46 AM
I'm still stuck with this problem
2015-12-16 09:11 AM
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.2015-12-16 10:35 AM
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.2016-01-12 04:19 AM
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 thishttp://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743/LN1734/PF257872
.-Hannibal-
2017-09-11 01:29 AM
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