This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Reset RTC time and date showing some strange behaviour

Dear Nordic

I have facing some issues in RTC side. In my application RTC and BLE works same time . First installation and set time using function nrf_cal_set_time() works fine both(RTC and BLE).

Again i try to reset the time and date  its show strange behavior (changing time and year continuously). I don't know my procedure to reset RTC time is correct or not i am just call the function nrf_cal_set_time() for setting date and time but its not work . can you help me to solve the issue?

Parents Reply Children
  • Thank you sigurd for your reply RTC in RTC2  its work fine first time but when i reset the time and date its its not working

    my cofiguration 

    #define CAL_RTC NRF_                   RTC2
    #define CAL_RTC_IRQn                   RTC2_IRQn
    #define CAL_RTC_IRQHandler        RTC2_IRQHandler

    procedure:

    RTC Init and set with time

    BLe Init

    every thing works fine(get time and date properly and BLE works fine)

    when i start to reset the time and date using  nrf_cal_set_time() its show strange behavior(time changing continuously) . i don't know what happen to RTC when i try to reset time again.

    observation:-

    i can set time once if i try to reset the time RTC fails 

    can you help me to solve this issue?

  • If you are setting a completely new and different time, e.g. adjust the new time with several days or years, it seems like the calibration will not work as intended.

    Try to remove the calibration offset, and see if that solves your issue. The nrf_cal_set_time() function will then look like this:

    void nrf_cal_set_time(uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t minute, uint32_t second)
    {
        static time_t uncal_difftime, difftime, newtime;
        time_struct.tm_year = year - 1900;
        time_struct.tm_mon = month;
        time_struct.tm_mday = day;
        time_struct.tm_hour = hour;
        time_struct.tm_min = minute;
        time_struct.tm_sec = second;   
        newtime = mktime(&time_struct);
        CAL_RTC->TASKS_CLEAR = 1;  
        
    	/* Commented out
    	
        // Calculate the calibration offset 
        if(m_last_calibrate_time != 0)
        {
            difftime = newtime - m_last_calibrate_time;
            uncal_difftime = m_time - m_last_calibrate_time;
            m_calibrate_factor = (float)difftime / (float)uncal_difftime;
        }
    	
    	*/
        
        // Assign the new time to the local time variables
        m_time = m_last_calibrate_time = newtime;
    }

  • Thank you sigurd for your support hope its work fine not test fully. I will update status soon

    anyway thanks

Related