Instruction manual
AMPDIO DRIVERS
Page 31
clock selections must be made by hand, and therefore a discussion of the calculations involved are
necessary to obtain the correct input clock source jumper selections.
MARK
SPACE
tM
tS
1 / freq
tM = msratio / freq where msratio = mark to space ratio
freq = output frequency (Hz)
tM = mark time (seconds).
The CDR for the 'mark' timer/counter, cdrM, is defined as
cdrM = tM x fClkM where fClkM = 'mark' timer's input clock frequency.
The equation for cdrM should be iterated for various values of fClkM, starting at 10 MHz and
working down, until the result gives a value for cdrM that is less than FFFF
16
(the maximum value
for a CDR). When this is attained, a suitable input clock frequency has now been found. A similar
calculation can now take place for tS, with
tS = (1 / freq) – tM
cdrS = tS x fClkS where tS = space time (seconds)
fClkS = 'space' timer's input clock frequency
cdrS = CDR for 'space' timer/counter.
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.
3.1.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. See section 6.4.7.
The TCsetStopwatch function 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.
3.1.5 Frequency/Period Measurement
Another use for the pulse generation capabilities of the 82C54 is for one counter/timer to provide a
precise GATE signal during which a second timer/counter counts an external event. In mode 0, a
high level on the gate input validates counting, and a low level invalidates it (i.e. counting stops).