[comp.sys.cbm] More accurate timer?

warren@col.hp.com (Warren Tustin) (12/19/90)

Is there a way to do timing on the C128 that is more accurate than the 
jiffy clock?  I assume it is possible, but has someone done it and could
send or post the routine?  I just need to be able to start a timer and then
look at the difference later.  Thanks for any info.

warren@col.hp.com

mroussel@alchemy.chem.utoronto.ca (Marc Roussel) (12/20/90)

In article <16200014@col.hp.com> warren@col.hp.com (Warren Tustin) writes:
>Is there a way to do timing on the C128 that is more accurate than the 
>jiffy clock?

The C64 is capable of a time resolution of about 1 microsecond.  The
method by which this is accomplished is documented in

Z. Szepesi, Transactor vol. 6, no. 4, pp. 35-37 (Jan. 1986).

The 6526 CIA's have general purpose timers that can count in
well-defined increments (not interrupted by I/O) up to 70 minutes.  (How
big these increments are exactly depends on which side of the Atlantic
you're on.  It's about 1us in both cases and the conversion factor from
clock ticks to seconds is calculable.  I'll let you read the article.)

				Marc R. Roussel
                                mroussel@alchemy.chem.utoronto.ca

cs4344af@evax.arl.utexas.edu (Fuzzy Fox) (12/20/90)

In article <16200014@col.hp.com> warren@col.hp.com (Warren Tustin) writes:
>
>Is there a way to do timing on the C128 that is more accurate than the 
>jiffy clock?

Yes, use one of the TOD clocks available on the 6526 chips.  They will
give you a measure of time to within a tenth of a second, and they
operate independently of the operation of the rest of the computer, so
disk access or other activities that disrupt the jiffy clock will not
affect them.

The clocks are located at $DC08-$DC0B and $DD08-$DD0B in memory.  For a
good treatise in programming the clocks (and the 128 in general) I
recommend "Mapping the Commodore 128," by Ottis R. Cowper, from COMPUTE!
Books.

-- 
begin 644 .signature
G5&AI<R!S<&%C92!I;G1E;G1I;VYA;&QY(&QE9G0@8FQA;FLN#0H:
 
end

grx0644@uoft02.utoledo.edu (12/20/90)

In article <16200014@col.hp.com>, warren@col.hp.com (Warren Tustin) writes:
> 
> Is there a way to do timing on the C128 that is more accurate than the 
> jiffy clock?  I assume it is possible, but has someone done it and could
> send or post the routine?  I just need to be able to start a timer and then
> look at the difference later.  Thanks for any info.

Warren,

The C128 has a hardware clock called THE TIME OF DAY clock. It is extreemly
accurate because it is driven by the interupts.......all you need to do is to
give it the starting value and it'll keep the time even during I/O procedures.
All you need to do is to read in the values and do a few simple conversions and
you'll have your time.  I wrote a routine, in ml, that will create a 'corner
clock' using the TOD clock.  I can send it out to anyone who can receive files
over the net.....

If you want the files, just email me directly.  Since Iam not at home
(currently in another city accessing my account via the net) I do not remember
the locations of the registers of the TOD clock.  Accessing them is not
straight forward and my programs are documented well enough to explain the
workings of the clock.

I hope this helps and I have not confused anyone (as it is very late and I am
sleepy).   :)

Tony