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

nrf calendar

can i genrate milliseconds using nrf calendar example?? that is only printing upto seconds i want milliseconds too??

  • power consumption is important to me is any any alternate  way to get milli seconds

  • Not by using the RTC peripheral, no. The most power efficient solution, I think would be to find a second low power MCU that is dedicated to tracking time at millisecond accuracy. If you insist on only using the nRF52, you will have to use the TIMER peripheral in order to achieve millisecond accuracy.

    Best regards,

    Simon

    UPDATE: I'm sorry, I was mistaken regarding the RTC. If you change the prescaler to 0 in the calendar example the RTC will run at the full 32.768kHz clock speed, and if you divide the RTC counter value by 32.768 you should get the current time in milliseconds. 

    The important factor is that you need to update all references to the CAL_RTC->COUNTER register, since this value will now be much higher (rather than increase by 8 every second it will increase by 32768 every second). 

    Also, the maximum time the RTC can run without being cleared will be much shorter, since the 24-bit RTC counter will overflow in 512 seconds when the prescaler is 0. 

  • omg i learned so much about rtc from you guys thanks and sorry for keep bugging you i grasped everything about that nrf calender except one thing why are  you using this function and what is the purpose of this function

    void nrf_cal_set_callback(void (*callback)(void), uint32_t interval)
    {
    // Set the calendar callback, and set the callback interval in seconds
    cal_event_callback = callback;
    m_rtc_increment = interval;
    m_time += CAL_RTC->COUNTER / 8;
    CAL_RTC->TASKS_CLEAR = 1;
    CAL_RTC->CC[0] = interval * 8; 
    },

    and also count=CAL_RTC->COUNTER /32.768; how can i print these 

    and also what happens when overflow occurs and how can i rectify that

    REGARDS

    MANIKANDAN V

  • Hi

    Torbjørn seems to have answered you in this thread.

    Best regards,

    Simon

Related