Instruction manual

AMPDIO DRIVERS
Page 33
3.1.8 Pulse Train Generation
By connecting the gate input of a frequency generator to the inverted output of another
timer/counter channel, it is possible to generate a fixed number of negative-going pulses within a
fixed period of time. These pulses will be narrow pulses if mode 2 is used for the frequency
generator channel (the ‘pulse’ channel), or square if mode 3 is used.
The duration of each train of pulses may be set by using the inverted output of a monostable
multivibrator (the ‘one-shot’ channel running in mode 1) as the gate input of the frequency
generator. The function TCsetOneShotPulseTrain described in section 6.4.8.20 allows a fixed
number of pulses to be output on the pulse channel during the one-shot pulse. The gate input of
the one-shot channel is used as the trigger.
By triggering the one-shot periodically from the output of a third timer/counter channel (the ‘train’
channel running in mode 2) a periodic pulse train generator is produced. The function
TCsetPeriodicPulseTrain described in section 6.4.8.7 allows the duration and number of pulses
within each pulse train to be set, and the frequency of the pulse trains to be set.
A variant of the periodic pulse train generator uses the inverted output of the train channel directly
as the gate input of the pulse channel directly with no one-shot channel between the two. The
duration of the pulse train is restricted to the period of the input clock for the train channel. The
function TCsetRestrictedPulseTrain described in section 6.4.8.14 uses this mechanism.
In all cases, only the ‘pulse’ (output) channel is specified and the other timer/counter channels are
offset from this. For boards with timer/counter clock connection registers and timer/counter gate
connection registers, everything can be set-up automatically by the functions. For the PC214E it is
necessary to wire up the gate inputs and trigger inputs manually on connector SK1 and to specify
to functions which of the predefined input clock sources to use, corresponding to the jumper
settings.
3.1.9 Pulse Width Modulation
It is possible to generate a frequency with a variable mark-to-space ratio by using the
TCsetAstable function (see section 3.1.3), but it is inconvenient to wire two one-shot monostables
back to back. An alternative is to use a single hardware-retriggerable one-shot triggered
periodically from the output of another timer/counter programmed in mode 2 to generate the
desired frequency. This connection can be made internally using the gate connection registers on
cards that have them. The TCsetPWMTrain function described in section 6.4.8.31 can be used to
set up such a frequency generator with programmable space-to-mark ratio. Related functions are
provided to change the space-to-mark ratio or the frequency after it has been set up.
The TCsetPWPulse function described in section 6.4.8.26 provides just the one-shot part of the
above without the frequency generator. This performs a similar function to the TCsetMonoShot
function, but the output low pulse duration is specified as an assumed overall period multiplied by a
space-to-mark ratio. Related functions are provided to change the space-to-mark ratio and the
overall period, but the function only has direct control over the length of the output low period.
3.1.10 Event Counter
Two timer/counter chips can be cascaded to provide a 32-bit count of clock pulses, which can
come from an external source. A clock pulse consists of a rising edge followed by a falling edge.
The TCsetEventCounter function described in section 6.4.7.8 provides this facility. The
TCgetEventCount function described in section 6.4.7.10 is used to read the current event count.
The count can be reset to zero by calling the TCresetEventCount function described in section
6.4.7.9. The function TCfreeEventCounter described in section 6.4.7.11 should be called to free up
the timer/counter resources when the event counter is no longer required.