Main Site Documentation

RTC vs system clock


#1

I am looking at using the RTC to track day, month , time etc. I’ve seen it stated that the RTC should be used to set the system clock…Is there a reason I’d need to use the system clock rather than just the RTC? I only need to monitor time when the unit is “on” & not lose track when unplugged from the wall (hence a coin cell).


#2

I would use system time


#3

The intent of RTC is that RTC keeps acurate time. The system may not. If you look at say the web server from Nicolas3 and Jasdev, you will see how they manage the RTC/system time setting. Then you can use the system time knowing it’s accurate.


#4

Well, all I want is to see the current time…what advantage is there for using the system time, then? Does using the RTC a lot adversely effect it somehow (perhaps battery life)?


#5

Not all mainboards have a RTC.

The system.time is a netmf core component; the RTC is mainboard specific, ie it might be different between any implementations. So from a commonality perspective, I’d just use system.time (that gets set once at startup, or periodically, from RTC)


#6

I suspect reading the system clock is faster and does not mask interrupts. See how long it takes to read the system clock 10000 times and the see how long it takes to read the RTC.


#7

You should only use RTC to update the system clock.

This is how windows or any OS handles time anyways.


#8

This all brings up an interesting question. If you have an application that runs continuously for months or even years, but only sets the system clock once at power on, will the system clock be less accurate than the RTC? If so should you resynchronize to the RTC periodically?


#9

I would. It’s no different to a network device going back to an NTP source periodically. In fact, if I had a RTC on a network capable device, I’d use NTP to set the time everywhere and refresh it periodically.


#10

I agree with Brett. I have not spent a lot of time characterizing the RTC, but from what I did see, it tends to drift and needs to be updated periodically.