Files
rtems/bsps/mips/shared/clock
Sebastian Huber d2600e03f2 bsps/mips/malta: Advance the compare register
Clock_driver_support_at_tick() set the compare register ahead of the
count register, so every period gained the latency of the interrupt.
Measured over 100 ticks, a period of 100000 counts took 100277, which
is 0.278 percent long.  sptimecounter02 measured a job of a fixed
number of clock ticks against the timecounter and failed with that
drift.  spintrcritical24 failed with it as well.  The dummy
timecounter hid the drift, because it took the uptime from the count
of ticks rather than from a counter.

Advance the compare register by the period.  A handler which runs late
computes a value which the counter already passed.  The comparison
then waits for the counter to run through its whole width.  That is 27
seconds at the frequency of this BSP.  Take the counter as the base of
the next period in that case, as the or1k clock driver does.

The period now measures 100000.08 counts.

Update #5742.

Assisted-by: Claude:claude-opus-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2026-09-21 20:02:55 -05:00
..