2016-04-14 04:48 AM
Hello,
I have noticed that when my system wake up from Standby mode seems to lose some time and RTC loses something like 2 ms for each secondDoes anybody have anytime this kind of problem?I have using an STM32L162.Any idea will be welcomedBest regardsCarmen2016-04-15 09:42 AM
Hi RiseOfDeath,
I think 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 AN where we have 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-
2016-04-18 01:44 AM
Hi Hannibal,
I have checked my code, comparing to AN4538, and they are equal.There must be something I'm doing wrong, but I cannot find it.Do you have any other suggestion?Thanks for your answerCarmen2016-04-18 03:35 AM
Hi Carmen,
Would you share your code to check with you ?Also, what is the hardware your are using and mention any connection are set-up .-Hannibal-2016-04-18 06:53 AM
Hi Hannibal,
First of all, thank you for your interest and help. Attached is our code. We are using a STM32L162RDT6. Best regards Carmen ________________ Attachments : main_-_copia.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtnY&d=%2Fa%2F0X0000000aX5%2F.zOC7hvs_VLfS67R46HBldg_prVpuMj_Mi27aUKDwpY&asPdf=false2016-04-18 10:47 AM
Hi Carmen,
I don’t think that you have implemented the same Power-on/resuming from standby conditionning as the AN example or as my recommendation. The hole project should be managed using the conditionning routine to handle only one time the RTC initialization and entering the standby mode at Power-on state (
PWR_FLAG_SB = 0)
. Otherwise the device always is resuming from standby (PWR_FLAG_SB = 1
) and making the treatment you want.if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) == RESET)
{
/* Power-ON RESET*/
- RTC configuration
- Entering standby routine
}
else
{
/*Resuming from standby */
………..
}
-Hannibal-
2016-04-18 11:55 PM
Hi Hannibal,
Sorry, but I think, I have implemented the same powerOn /resuming from StandBy functions as AN example. I have configure RTC, just when (PWR_FLAG_SB = 0),
in function MX_RTC_Init(). Other times, when system wakeUp from StandBy, RTC is not initialized.
I think this is not the real problemThank you very muchCarmen2016-04-21 10:05 AM
Hi fernandez.sergio,
Try to put the RTC instance initialization outside MX_RTC_Init() in the biginning of main() (before if condition) like this :/* Initialize the RTC instance*/
RTCHandle.Instance = RTC;
if (__HAL_PWR_GET_FLAG(PWR_FLAG_SB) == RESET)
{
/* Power-ON RESET*/
- Mx_RTC_init()
- Enter standby mode
}
else
{
/*Resuming from standby */
}
Tell me if this reslove your problem.
-Hannibal-
2016-04-24 11:01 PM
Hi Hannibal.
Thank you for your new suggestion. I have tried, and the result is exactly the same.Best regardsCarmen2016-04-25 06:46 AM
Hi fernandez.sergio,
I recommend that you should create a simple/short project from your original one that duplicate the issue to investigate clearly the cause. -Hannibal-