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

RTC0 nrf 52 read counter value

Hi,

I am new to the nrf52. I want to implement the code that gives me current date and time value based on default set values.

for this i need to read the current counter value. Can any one tell me the simplest way to read the current counter value in RTC0?

Also is there any sample code related to date and time calculation in nrf52??

Please give reply.!!!!

Parents
  • Hi,

    First I must stress that the real time counter (RTC) is a timer. It is not, as the abbreviation "RTC" may suggest, a real time clock. However, it runs off the 32 kHz clock and can be used to keep track of time within the accuracy of that clock signal.

    You will find that the Real Time Counter Example of the latest SDK uses RTC on the nRF52.

    For date and time calculation I suggest that you use an existing time and date library, since there are a lot of pitfalls when working with time and date. I think the ctime standard c library would be a good choice. Most likely the time_t format will be a unix timestamp and it should be safe to increment a "current time" value of this type every second to keep it up to date.

    Regards, Terje

  • Hi,

    i am able to read the value of counter by using

    count = NRF_RTC0->COUNTER;

    Thanks for your support!!

Reply Children
No Data
Related