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

getting millis from startup

I need to count millis from nrf52 start

I have seen that all are using rtc1 but I did not find any example from which i can integrate it to my project.

  • Hi Dhaval!

    The reason that "all are using RTC1", is because the softdevice is using RTC0.
    We do have an RTC example in the SDK that you can take a look at.
    Located at; sdk_location/examples/peripheral/rtc

    The Real Time Counter (RTC) uses the low-frequency clock source (LFCLK, 32KHz). That means less resolution (~30us) and lower power consumption. The RTC features a 24 bit Counter and a 12 bit prescaler.

    When using prescaler value 0 the RTC will overflow after 512 seconds, with a period of 30us.
    With a max. prescaler value the RTC will overflow after ~582.5 hours, with a period of 125ms.

    I don't know what SDK you are working with, so I just assume SDK 14.2.0.
    To implement such a counter in your project, I would suggest that you take a look at the Application Timer in the infocenter.
    The function app_timer_cnt_get() can be used to get the current value of the RTC1 counter. Then you need to convert the number of ticks to ms.

    Take a look at my answers in these cases, that might be of interest.
    devzone.nordicsemi.com/.../
    devzone.nordicsemi.com/.../

    Hope that helps, but be sure to let me know if you face any problems.
    Best regards,
    Joakim

Related