Date : Fri, 23 Sep 1994 11:17:44 -0600
From : barnett@... (David Barnett)
Subject: 6522 timer emulation suggestion
>Re: 6522. Ideally it should be a separate process but alas there isn't enough
>raw computing power available for the timers.
There is no need to increment the timers on every cycle.
1. Maintains 32 bit instruction cycle counter (ICC) which is incremented
on every cycle. This number should in effect be in units of 0.5us for a
standard BBC Micro with 2MHz clock. Note that when accessing much of the
memory-mapped I/O the CPU clock was slowed to 1 MHz for that memory cycle.
Some programs even took this into account (the Music 5000 for example).
2. When a via timer is set up, record the ICC and an ICC prediction for
when it will set the interrupt.
3. On a via timer read, simply perform arithmetic based on the current ICC
and the remembered ICC from the setting. This will include dividing by the
cycle to count factor (2 for a standard 2MHz BBC micro).
4. If the ICC passes a predicted interrupt time then an IRQ can be generated.
5. To avoid problems off number wrap after about 2000 seconds of 'real'
time, the ICC and all numbers referred to it could be decermented by 2^24
every 2^24 cycles.
David Barnett