Timer Device Specification

Memory Layout

ByteModeNameDescription
00-01R y current year
02R m current month (0 = January, 1 = February, ... , 11 = December)
03 R d current day
04-05R yd (unix only) current day of the year (0-355)
06 R dst (unix only) 1 if daylight saving time else 0
07 R wd current day of the week (0 = Sunday ... 6 = Saturday)
08 R always zero
09 R h current hour
0A R m current minute
0B R s current second
0C-0FR ms current total time since midnight on the day of system start in milliseconds
10-13RWt Offset: number of milliseconds to wait for interrupt
14-17RWi Interval: number of milliseconds to repeat interrupt
18-1BRWt0 t0: base time for next interrupt in milliseconds
1C-1FRWdt dt: delta time for next interrupt in milliseconds

Current Time and Date

The values y, m, d, dst, yd, wd, h, m, s, ms specify the current time and date as given by the host operating system. The value of ms will grow larger than the number of milliseconds of a single day, if the system runs over midnight. It will wrap around eventually after approximately 50 days. These values are read only.

Timer Interrupts

The timer uses the interval i and offset t (both in milliseconds) to specify timer interrupts. If t is set to a non-zero value, the timer will wait t milliseconds and then raise an interrupt. If at the time of the interrupt i has a non-zero value, the interrupt will be repeated i milliseconds later again (until i is set to zero).

If the timer offset t is set while the timer is already waiting, the waiting period will start over from zero to the new value of t.

If the timer offset t is set to zero, there will be no further interrupts.

Reading the timer offset t will return zero, if there is no interrupt pending. It will return a nonzero value if there is an interrupt pending. The value will not reflect the time remaining until the interrupt occurs but the value last written to t. To obtain the remaining time you should read t0 and dt (see below) and compare the result with the value read from ms.

Reading the timer interval i will return a nonzero value if the inerrupt will repeat after it ist raised. It will return zero if there is only a single (or none) interrupt in the future.

If the timer interval i is set to a different value, this change will have an effect only at the time the next interrupt occurs.

The values t0 and dt are an alternative way to specify t. Setting t will automatically set t0 and dt, while setting t0 and/or dt will automatically set t.

Storing a value to either t0 or dt will cause the timer device to wait until the absolute time ms reaches the value t0+dt and then raise an interrupt. The value of t0 is allways assumed to be in the past. So even if the value ms wraps around you can get reliable timer interrupts. Setting t0 and/or dt is (almost, except for setting t to zero) the same as setting t to t0+dt-ms.

There is a slight difference between the use of t and of t0/dt. An interrupt will occur immediately if t0+dt is less or equal to ms (a time in the past). Storing to t0/dt can therefore not be used to disable or stop interrupts. For this purpose store zero to t (t is always in the future).

In the other direction, storing a nonzero value to t is the same as storing ms to t0 and t to dt.

As soon a the timer expires, t0 is set to t0+dt and dt is set to ti. If ti is not zero, this will also schedule the next interrupt.

The use of t0 and dt, is necessary if repeated use of the timer should not result in a timer drift. If, for example, an interrupt is needed at the beginning of every second and 10 millisecond after the full second, using the timer interval is not efficient. Using just the offset t will cause the timer to slowly drift because of the computation needed between sending the interrupt and reseting it again. In this case, the application should read ms at the very beginning of the program keeping the value in a local base variable. Then it can call for the first interrupts at t0=base, dt=1000 a second later. The next interrupt is then requested at t0=base+1000, dt=10. Further interrupts are called for at t0=base+1010, dt=990; t0=base+2000,dt=10; ... The time to reschedule the interrupt will not cause a timer drift, since the time of the interrupt is specified as an absolute time.

Timer Configuration

The timer has the following configurable parameters:

host localhost the host where the bus is located
port 9002 the port where the bus is located
address default address where the resource is located
interrupt default interrupt send by device
x 0the x position of the window
y 0the y position of the window
minimized falsestart with a minimized window
debug falseto generate debug output
debugmask 0xFFF0 set mask to hide debug output
verbose falsemake debugging verbose, sets debug mask to zero
define not setto define a name for conditionals
config not setfilename for a configuration file
help falseto print information
These should be set in default.vmb Later versions of the timer device might specify a resolution, to change the units of ms, t, i, t0 and dt. Currently, only a millisecond timer is available.