Sub-second timer?

Feel free to discuss any Organiser II related topic here
Post Reply
Posts: 19
Joined: Mon Dec 20, 2021 4:55 am

Sub-second timer?

Post by toml12953 »

Is there a way to measure time in increments of less than one second?
I know I can start the program with

Code: Select all

then at the end of the program use

Code: Select all

t=hour*3600.0+minute*60+second - t
to get the runtime in whole number of seconds but I'd like a finer measurement like centiseconds or milliseconds.
User avatar
Posts: 128
Joined: Wed Jan 27, 2021 3:44 pm

Sub-second timer - TechRefManual

Post by MartinReid »


The Republished Technical Reference Manual (here) discusses 'milliseconds' and Appendix C has a list of system services. I wouldn't know how to 'call' them but maybe there is something there..


PS I'll try your benchmarking at the week end...
Posts: 43
Joined: Sun Aug 22, 2021 6:56 am

Re: Sub-second timer?

Post by amenjet »

The real time clock/calendar of the organiser uses 1Hz signals to update so sub second timing isn't possible with that.
There are free running timers in the 6303 as the technical manual states:

The timer 1 compare interrupt is used to scan the keyboard to allow
keyboard buffering and to provide a timing service. This interrupt is
referred to in the documentation as the KEYBOARD INTERRUPT (KI). The
interrupt is generated every time the free running counter matches the
count in the timer 1 compare register. As the free running counter is
being clocked by the system clock of 921600 HZ, extremely accurate timing
can be performed using this interrupt. The time between interrupts is
controlled by the variable KBW_TDEL which is initialised on cold start to
be $B3DD. This value makes the KI interrupt occur exactly every 50
milliseconds and is used extensively by the operating system for timing
purposes. The value in KBW_TDEL can be changed, but all system timing will
be destroyed as a result and the operating system may fail to perform
Timer 1 is 16 bits so will wrap really quickly. If you wanted to time something short then you could possibly use this but you'd probably be better off
using a machine code loop. For longer periods of time you could hook in to the keyboard scanning/timer 1 conmpare interrupt and run some code that
increments a 32 bit or 64 bit number every so often. That would give you a number that increments every few 10's of ms (50ms is the default, i think) and would last for long periods of time.

There's this system variable:
dpw_redy 6D/6E Decremented every 50ms (on keyboard interrupt) until it is zero. Used for timing, e.g. by DP$WRDY and TM$WAIT.
which does count on each keyboard interrupt, but it will also wrap fairly quickly.

All the interrupt vectors go through RAM so can be hooked in to.

I'm definitely not an expert at this so there may be a better way...


Post Reply