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

nrf_calendar set time

Hi Nordic Team,

On my project, I added nrf_calendar using the Softdevice using the SDK 14,

the calendar is working fine most of the time. but I have an issue when I tried updating the data time using nrf_cal_set_time for the 2nd time, it is not incrementing anymore and keep printing the same values

behaivor:

1) Init calendar on main calling  calling nrf_cal_init()

2) set data time using nrf_cal_set_timefor example, today 07/11/18 06:15:07 (works fine... calendar working fine after, hours, days)

3) print data time using printf("Calibrated time:\t%s\r\n", nrf_cal_get_time_string(true)); (fine)

the issue starts here:

4) updating the data time using nrf_cal_set_time for 2nd time or more keeps printing the same value not increasing the time

for example, if use  nrf_cal_set_time to update to 07/11/18 18:30:00 it keeps printing 07/11/18 18:30:00 over the time with not increasing 

Can someone give an advice with it?

my initialization code makes it works with the softdevice for sdk15

void nrf_cal_init(void)
{
    // RTC2 and the 32 kHz crystal  
    CAL_RTC->PRESCALER = 0xFFF;
    CAL_RTC->EVTENSET = RTC_EVTENSET_COMPARE2_Msk;
    CAL_RTC->INTENSET = RTC_INTENSET_COMPARE2_Msk;
    CAL_RTC->CC[0] = m_rtc_increment * 8;
    CAL_RTC->TASKS_START = 1;
    NVIC_SetPriority(CAL_RTC_IRQn, CAL_RTC_IRQ_Priority);
    NVIC_EnableIRQ(CAL_RTC_IRQn);  
}

// on nrf_calendar.c

void CAL_RTC_IRQHandler(void)
{
    if(CAL_RTC->EVENTS_COMPARE[0])
    {
        CAL_RTC->EVENTS_COMPARE[0] = 0;     
        CAL_RTC->TASKS_CLEAR = 1;
        
        m_time += m_rtc_increment;
        if(cal_event_callback) cal_event_callback();
    }
}

//interruption hanlder on nrf_calendar.c

void CAL_RTC_IRQHandler(void)
{
    if(CAL_RTC->EVENTS_COMPARE[0])
    {
        CAL_RTC->EVENTS_COMPARE[0] = 0;     
        CAL_RTC->TASKS_CLEAR = 1;
        
        m_time += m_rtc_increment;
        if(cal_event_callback) cal_event_callback();
    }
}


// on nrf_calendar.h

#define CAL_RTC                 NRF_RTC2
#define CAL_RTC_IRQn            RTC2_IRQn
#define CAL_RTC_IRQHandler      RTC2_IRQHandler
#define CAL_RTC_IRQ_Priority    3

Regards

Parents Reply Children
No Data
Related