RTC is not updating properly during power off

Hi Team,

I am working on S7G2 custom board. RTC is updating properly when power is there.

But when there is no power it is not updating.

Below are my doubts and trails to verify the issue: 

1. External CMOS battery is connected, and verified it is giving correct supply during power off

2. Clock is selected as sub cycle instead of LOCO ( based on one of response as per forum) 

3. Tried to verify using EVAL board, but it doesn't have CMOS battery support 

4. Tried with different custom board ( to verify this is only with this board)

What is causing it not updating during power off, even though battery backup provided.

Please suggest,

Thanks,

Sreeman

  • Hello Sreeman,

    Please make sure that CGC driver is set to not stop sub-oscillator on start-up (reconfigure sub-clock set to disable). You can investigate following project to see how RTC operation is retained over resets/powerdowns: s7_sk_ux_mass_rtc_capture_1_4_0.zip

    Regards

  • In reply to Renesas Karol:

    Hi Karol,

    We are using 1.3.0 SSP for all our low level driver implementations. (The example you have provided is for 1.4.0 - as it is not possible to change the SSP right now, it will help us if u share the example in 1.3.0.) Below is the code snippet we are using:


    void init_rtc(void)
    {
    ssp_err_t err = SSP_SUCCESS;
    rtcTestVal++;
    err = g_rtc.p_api->open (g_rtc.p_ctrl, g_rtc.p_cfg);
    if (err == SSP_SUCCESS)
    {
    err = g_rtc.p_api->periodicIrqRateSet (g_rtc.p_ctrl, RTC_PERIODIC_IRQ_SELECT_1_SECOND);
    if (err == SSP_SUCCESS)
    {
    err = g_rtc.p_api->calendarCounterStart (g_rtc.p_ctrl);
    if (err == SSP_SUCCESS)
    {
    err = g_rtc.p_api->irqEnable (g_rtc.p_ctrl, RTC_EVENT_PERIODIC_IRQ);
    if (err == SSP_SUCCESS)
    {
    #ifdef SEMI_HOSTING
    if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)
    {
    printf ("RTC init success\n\r ");
    }
    #endif
    /* Set Calendar Time */
    // err = g_rtc.p_api->calendarTimeSet (g_rtc.p_ctrl, (rtc_time_t *) &start_time, true);
    // if (err == SSP_SUCCESS)
    // {
    // rtcTestVal++;
    // return;
    // }
    }
    }
    }
    }

    }

    void rtc_setTime(void)
    {
    err = g_rtc.p_api->calendarTimeSet (g_rtc.p_ctrl, (rtc_time_t*) &start_time, true);

    if (err == SSP_SUCCESS)
    rtcTestVal = 0;
    else
    rtcTestVal = -10;
    }

    void rtc_getTime(void)
    {
    rtc_time_t get_time;

    err = g_rtc.p_api->calendarTimeGet (g_rtc.p_ctrl, &get_time);

    if (err == SSP_SUCCESS)
    rtcTestVal = 0;
    else
    rtcTestVal = -10;

    // Read to global variable
    err = g_rtc.p_api->calendarTimeGet (g_rtc.p_ctrl, &CurrentTime);

    // sprintf (n8RxUartBuffer, "Time: Hr:%d, Min:%d, Sec:%d, Date:%d, Month:%d, Year:%d\n\r ", get_time.tm_hour, get_time.tm_min, get_time.tm_sec, get_time.tm_mday, get_time.tm_mon, get_time.tm_year);
    // uart_send_data (n8RxUartBuffer);
    }

    void rtc_callback(rtc_callback_args_t * p_args)
    {
    (void) p_args;

    if (p_args->event == RTC_EVENT_PERIODIC_IRQ)
    {
    rtc_getTime ();
    }
    }

    Also attached image is the property set for RTC in configuration.xml

    1. Please suggest the modifications required.

     

    2.With RTC_EVENT_PERIODIC_IRQ will achieve RTC increment during power off ??

    Thanks,

    Sreeman

  • In reply to Sreeman:

    Hi Sreeman,

    If you open the RTC driver at the earliest point your application then you'll only notice a little drift upon every startup (again, resolved in 1.4.0 and newer) provided the rest of the congiuration is correct.

    RTC is counting regardless of the interrupt configuration (although it's recommended that you leave the carry interrupt enabled). You will not notice any interrupts in the battery-backup mode as everything but the VBAT domain (RTC and backup registers) is powered down.

    I have an older example which may work well for you: s7_dk_gx_rtc_stop_det_1_3_0.zip. It includes an additional routine to check whether RTC has been stopped when MCU was powered down (i.e. the battery was removed or gone flat) - you can use that to tell your software to re-initialize RTC with some known start date/time.

    Regards