View Full Version : RTC Emulator ?

07-06-2009, 08:30 PM

Anyone got any samples of doing date maths with this object?

eg. Say I want the same thing to happen every day at a certain time. Would I have to start parsing the strings?

If one wasn't using the RTC object would it be possible to do a waitcnt(6912000000000 + cnt) as representing a 24 hour wait...seems a bit odd.

Many thanks


07-06-2009, 08:56 PM
Why do you need date math for your problem? Why would you have to parse the string?

Just do a string-compare with a time string you set in your program in format hh:mm:ss like "12:30:25".

You can't do a waitcnt( a_vew_hours_later ;o) ... The internal counter is 32 bits, which gives you a max. waittime of ~50sec at 80MHz.

07-06-2009, 10:23 PM
When I was in the irrigation industry (designing sprinkler timers) we used to create as single value from the minutes and hours -- 0 (midnight) to 1439 (11:59:xxPM); this is easy to do: (hrs * 60) + mins. If you need more resolution you could convert your rtc values to raw seconds: (hrs * 3600) + (mins * 60) + secs; this would give you a value between 0 (midnight) and 68399 (11:59:59PM).