Instruction manual

Table Of Contents
PC215E Page 18
MARK SPACE
tM tS
1 / freq
msratio = tM / (tM + tS) where
msratio
= mark to space ratio
tM = mark time (seconds).
tS
= space time (seconds).
freq = output frequency (Hz)
Note: the 82C54 timer/counters outputs are switched to the low level by the
next clock
after the
gate trigger, possibly causing the mark-to-space ratio to become distorted by one or two clock
pulses. This will become more apparent at higher frequencies.
4.2.4 Stopwatch
In mode 2, the output of the 82C54 timer/counter starts high; goes low for one clock pulse when
the count value decrements to 1, and then is set to high again. The initial count value is then
automatically re-loaded; counting continues and the sequence repeats. The output can be used
as a clock signal for another timer/counter, and any number of timer/counters can be cascaded
in this way.
Section 6.6.7 "Millisecond Stopwatch Functions" contains function TCsetStopwatch which sets
up two timer/counters in this way with a clock input frequency of 1 kHz. Function
TCstartStopwatch
sets the counters counting, and function
TCgetElapsedTime
latches and
reads the two count values to calculate the elapsed time, in milliseconds, since the counters
were first set off by TCstartStopwatch. This stopwatch can count milliseconds for nearly 50
days. Function
TCfreeStopwatch
releases the timer/counters so they can become available for
use by another application when the stopwatch is no longer required.
4.2.5 Event Recorder
An extension of the stopwatch described above is to record the elapsed times when an external
event occurs. This is possible by connecting an event's status output to an 82C55 digital input
channel on SK1, and causing this digital input to generate an interrupt to the computer's CPU.
The interrupt service routine would then read the elapsed time from the stopwatch
timer/counters and store the time into memory.
The function described in section 6.6.7.4 "Prepare an Event Time Recorder -
TCsetEventRecorder" allows you to specify a digital input chip (PPIX or PPIY) from which Port
C bit 0 will be used as the event input, and interrupt source. Once the board's interrupt has
been enabled (see function enableInterrupts - section 6.6.2.1) and a stopwatch timer has been
started, a positive going signal on the PPI Port C bit 0 pin on SK1 will cause the elapsed time to
be recorded into memory.