Skip to main content
chief
Associate II
October 1, 2015
Question

RTC lost time after reset

  • October 1, 2015
  • 2 replies
  • 807 views
Posted on October 01, 2015 at 14:14

I've STM32f417IF. I try to user RTC. All Init code writed by STMCubeMX. Then i set date and time, but after reset RTC time clean again.

RTC have own big capasitor and i just make reset, without poweroff.

What is wrong?

upd.

I'm idiot. Standart Cube's init set zero time. 

Moderator, pls remove this stupid topic.
    This topic has been closed for replies.

    2 replies

    thomfischer
    Senior
    October 2, 2015
    Posted on October 02, 2015 at 21:04

    in function void MX_RTC_Init(void)

    disable

    HAL_RTC_SetTime(&hrtc, &sTime, FORMAT_BCD);

    HAL_RTC_SetDate(&hrtc, &sDate, FORMAT_BCD);

    Walid FTITI_O
    Visitor II
    April 14, 2016
    Posted on April 14, 2016 at 16:23

    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-