Instruction manual

Table Of Contents
Page
19
PC215E
4.2.6 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). Also a low-to-high transition on the gate input causes the initial count value to be re-
latched into the counting element.
Section 6.6.8 contains two functions TCgetExtFreq and TCgetExtPeriod both of which program
a timer/counter to provide a one-shot gate pulse of precise duration 6.5535 ms to a second
timer/counter. The second timer/counter has an external signal as its clock input. When the
gate pulse is over, the second timer/counter's counting stops, and its value is then read. A
simple calculation can then be made to determine the number of external clock cycles received
during the 6.5535 ms, and from this the external frequency and period can be estimated.
The timer/counter you specify in calls to TCgetExtFreq and TCgetExtPeriod is the second
timer/counter described above: The input frequency range supported by
TCgetExtFreq
is 153
Hz to 10 MHz, and the input period range supported by TCgetPeriod is 6.54 ms to 100 ns.
4.2.7 Frequency Generation
In mode 3 the output of the timer/counter is a periodic square wave, whose frequency is the
input clock frequency divided by the programmed counter divide ratio (CDR). The function
TCgenerateFreq
described in section 6.6.8.3 calculates the CDR required to generate a specific
frequency on a given timer/counter. The function automatically selects an appropriate input
clock frequency.
The function
TCgenerateAccFreq
described in section 6.6.8.4 uses two cascaded
timer/counters, both in mode 3. The flexibility of having two CDRs adds another degree of
freedom into the calculation of the CDR values, and a more accurate output frequency can be
attained.
4.2.8 Frequency Multiplication
An extension of the frequency measurement and frequency generation capabilities described in
sections 4.2.6 and 4.2.7 above is to combine the two into a process that measures an external
frequency on one timer/counter; multiplies the frequency value by a given factor and generates
this new frequency on a second timer/counter. Function TCmultiplyFreq described in section
6.6.8.5 performs this operation.
4.2.9 Digitally Controlled Oscillator
The combination of the 82C55 PPI and 82C54 counter/timer devices on the PC215E board
make it possible to implement a digitally controlled oscillator, whereby the value of a binary
number read into a PPI input channel is used to calculate the frequency of a square wave
generated on a timer/counter output. To turn this process into a continuous background task, a
second timer/counter can be deployed to generate an 'update' signal by generating a periodic
interrupt. The interrupt service routine then performs the DCO operation in the background.
Function TCsetDCO (section 6.6.9.1) sets up such an arrangement - allowing you to specify the
digital input channel, the output timer/counter and the second timer/counter used to generate
the 'update' interrupts. The function also allows for a flexible update rate and output frequency
range. The digital input channel width (i.e. the number of bits in the digital input word) can be