[comp.sys.cbm] C64 clock

ron@vicorp.com (Ron Peterson) (02/08/91)

Does anyone know how to get accurate clock times out of a C64?  I've tried
TI$, TI, TOD timer for CIA #1 and #2 and they all slip by several seconds
each hour.  I remember seeing a code fragment, about 5 or 10 lines long,
that showed how get an accurate timing based on the crystal rather than
the 60Hz input to the CIA's.
ron@vicorp.com or uunet!vicorp!ron

root@zswamp.fidonet.org (Geoffrey Welsh) (02/11/91)

In a letter to All, Ron Peterson (ron@vicorp.com ) wrote:

 >Does anyone know how to get accurate clock times out of a 
 >C64?  I've tried TI$, TI, TOD timer for CIA #1 and #2 and
 >they all slip by several seconds each hour.

   TI (from which TI$ is derived) will be put 'on hold' whenever a serial device 
or cassette is accessed.  If you have a Kernal 1 ROM, it's worse: the divisors 
in ROM are incorrect (they assume 1.00 MHz in stead of 1.02).  Some K2 ROMs foul 
up and load the PAL divisor (based on .98 MHz) in stead of the NTSC divisor!

   The CIA should be as accurate as your AC supply frequency, which isn't very 
good over the short term but should be dead accurate in the long haul (after 
all, it's what clocks run on... your hydro company should go out of their way to 
adjust the frequency every once in a while and bring drifting clocks back in 
line).

 >I remember seeing a code fragment, about 5 or 10 lines long,
 >that showed how get an accurate timing based on the crystal 
 >rather than the 60Hz input to the CIA's.

   That might have been something as simple as loading the correct divisors 
into the CIAs, or using VIC interrupts in stead... both of which are subject to 
pauses during disk I/O.  The CIAs are your best bet.

   Geoff
 




--  
UUCP:     watmath!xenitec!zswamp!root | 602-66 Mooregate Crescent
Internet: root@zswamp.fidonet.org     | Kitchener, Ontario
FidoNet:  SYSOP, 1:221/171            | N2M 5E6 CANADA
Data:     (519) 742-8939              | (519) 741-9553
The mile is traversed not by a single leap, but by a procession of coherent 
steps; those who insist on making the trip in a single element will be failing 
long after you and I have discovered new worlds.        - me