Port-amiga archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Timer issues?



On Thu, 13 Aug 2009, Frank Wille wrote:

For an eclockfreq of 715909 the amiga_clk_interval becomes 7159. Following
the algorithm from above it will render a counter_mask of 0xfff.

IMHO it is wrong when applying a mask of 0xfff to the result of the
tc_get_timecount() function, which, in the amiga/dev/clock.c case, returns
the hardclock_ticks * amiga_clk_interval + clock_tick (read directly from
CIA timer). A mask of ~0 should work better.

But I would not dare to revert the code, because Michael wrote that he fixed
a bug with negative values. There may be a problem somewhere else. Maybe
Michael could comment on that.

  The timecounter code uses the mask to limit the number of bits from the
counter to use in its computations.  Setting the mask to more bits means
using more bits of the counter that in the calculations, but the counter
can never set any of those bits, and it messes up the calculations.  This
was mentioned in the document that Frank Kardel referenced when timecounters were first introduced to NetBSD.

  I ran into the same problem with the vax interval counter - it's a 32
bit counter, but counts from something like -100 to -1 and resets. Both the original amiga code and the vax code came from the same person who likely either didn't realize the amiga and vax counters aren't free-running 32 bit counters or else didn't know that the counter mask needed to be set.

What's the "191" mean? 191 x 10^5? It doesn't make much sense.

  That means that the hz value needs to be at least 191 (amiga uses
100Hz interval).  That could be done by running the amiga with a 200Hz
interval, but I think that would involve using a smaller counter in the CIA, with a resulting smaller counter mask, which would then get you back
to the same problem.

On mac68k and VAX, similar values are suitable:

Yes, 700kHz should be enough. It's a bug in Amiga's clock.c.

  The interval counter on the vax is not suitable, since it's also a
short counter like the amiga.  One of the vax models (4000/60 maybe)
has a diagnostic conter, which is a free-running 32 bit counter.

--
Michael L. Hitch                        mhitch%montana.edu@localhost
Computer Consultant
Information Technology Center
Montana State University        Bozeman, MT     USA


Home | Main Index | Thread Index | Old Index