Skip to main content

RTC time not accurate

DA1469x

5 months ago

Posted by jagath52 75 points 7 replies
0 upvotes

Hello

I am using Social distancing tag example with wira sdk.

I am using Da14695 MCU for our wrist band and it has LCD to display time.

Mobile application will send time HH:MM:SS and day:mon:year, but after 2 days the time is 2 minutes behind the actual time.

I am using deep sleep to reduce current consumption.

Thank you
Jagath

 

5 months ago

PM_Dialog

Hi jagath52,

Thanks for your question. Can you please share the RTC configurations that you are using in the application code?

This is replicated only when the DA14695 is in deep sleep?

Thanks, PM_Dialog

5 months ago

jagath52 75 points

Hello 

This is the rtc start 

I have commented hw_rtc_set_time_clndr() to avoid re-initialization of time when the device wakes up from deep sleep.

static int LOG_InitTimestamp(void)
{
        int Status;

        /* Check if this is the first time the device is powered */
        if (TimestampMagicValue != LOG_TIMESTAMP_INIT_MAGIC_VALUE) {
//                Status = hw_rtc_set_time_clndr(&time_cfg, &calendar_cfg);

//                if (Status != HW_RTC_VALID_ENTRY) { //! Any invalid entry should cause failure
//                        ASSERT_WARNING(0);
//                        return LOG_STATUS_INVALID_TIMESTAMP_DEFAULT_VALUES;
//                }
                /*
                 * Designate that RTC initialization has been performed
                 * (valid as long as the device is powered).
                 *
                 * \note Alternately, the magic value can be stored in the flash memory used
                 *       so the device is not re-initialized following power failure.
                 */
                TimestampMagicValue = LOG_TIMESTAMP_INIT_MAGIC_VALUE;
        }
        hw_rtc_clock_enable(); //! Make sure the clock gating is activated
        hw_rtc_start(); //! Make sure both time and calendar timers are activated

        _VERBOSE_(VERBOSE_STATE, %s, __func__)
        return LOG_STATUS_OK;
}

 

This function is to receive the time and date from a mobile application

 

static void cts_set_time_cb(ble_service_t *svc, uint16_t conn_idx, const cts_current_time_t *time)
{
        int status;

        /* check if the passed time is valid */
        if (!cts_is_current_time_valid(time)) {
                /* if not return wit error indicating that the time set was ignored */
                cts_set_time_cfm(svc, conn_idx, CTS_ERROR_DATA_FIELD_IGNORED);
                return;
        }

        /* copy the CTS time/date to RTC time/date */
        calendar_cfg.year       = time->date_time.year;
        calendar_cfg.month      = time->date_time.month;
        calendar_cfg.mday       = time->date_time.day;
        time_cfg.hour           = time->date_time.hours;
        time_cfg.minute         = time->date_time.minutes;
        time_cfg.sec            = time->date_time.seconds;
        calendar_cfg.wday       = time->day_of_week;

        /* set the ne time/date to RTC */
        status = hw_rtc_set_time_clndr(&time_cfg, &calendar_cfg);

        if (status != HW_RTC_VALID_ENTRY) {
                /* if any invalid entry detected reject time update */
                cts_set_time_cfm(svc, conn_idx, CTS_ERROR_DATA_FIELD_IGNORED);
        }

        /* Inform the CTS service that the time is set */
        cts_set_time_cfm(svc, conn_idx, ATT_ERROR_OK);
}
 

 

 

 

 

 

Deep sleep

I am using deep sleep to put the device into sleep when not in use 

Is there any effect for rtc if I am using deep sleep

 

 

Thank you
Jagath

5 months ago

PM_Dialog

Hi jagath52,

Which is the Low Power Clock (LPC) that you are using? Is it the internal RCX, or an external XTAL? 

>> but after 2 days the time is 2 minutes behind the actual time

So, the DA1469x is configured in deep sleep for 2 days, and when it wakes up the time is 2 minutes below? 

Thanks, PM_Dialog

5 months ago

jagath52 75 points

Hello PM_Dialog

1. Low power clock is xtal 32K

#define dg_configUSE_LP_CLK                     ( LP_CLK_32768 )

 

2. Device will go to deep sleep randomly like
           a. Based on gpio press
            b. Based on activity

3. Deep sleep maybe after 5min, 1 Hour, or even 1 day.

4. Device will stay in deepsleep may for 5 min, 1 hour, or for more than 1 day

 

Thank you
Jagath

5 months ago

PM_Dialog

Hi jagath52,

Thanks for the clarification. Please put the device into deep sleep mode and wake it up after ~1 hour. Can you detect an RTC drift in the first wake up? Apologies for the question but I’d like to understand what is getting wrong.

Thanks, PM_Dialog

5 months ago

jagath52 75 points

Hello 

 

No for 1 or 2-hour sleep there is no drift

 

Thank you
Jagath

5 months ago

PM_Dialog

Hi jagath52,

Sorry for the delay. So, you can replicate this if you wake it up multiple times for days?

Thanks, PM_Dialog