Chapter 8: Programmable Interval Timer
Manual Number: 00650-014-4
Page 8-5
task = 14; /* counter setup mode task */
params[0] = 0;
/* setup counter #0 */
params[1] = 2;
/* set counter #0 mode to 2 */
params[2] = 0xffff;
/* set counter #0 count to ffff hex (65535) */
a12drv(FP_OFF(task),FP_OFF(params),FP_OFF(status)); /* call the driver */
Next, apply the number of pulses to be counted. The gate input, pin 21, must now be high or can be
taken high for some fixed time interval to control the number of pulses counted. You can read the
new count using TASK 15 of the driver:
task = 15; /* read counter count task */
params[0] = 0;
/* read counter #0 */
a12drv(FP_OFF(task),FP_OFF(params),FP_OFF(status)); /* call the driver */
Upon return, params[1] contains the counter contents.
Triggering A/D Conversions Periodically
When you are using the A/D converter on AD12-8, one of the key uses for the programmable
interval timer is to provide start pulses for periodic sampling. The TMR/EXT jumper should be in
the TMR position. You can set up an output frequency by using Task 14 to load Counters #1 and #2
with the required divisors.
For example, assume that a trigger rate of 8.3 KHz is needed. First, work out the overall division
ratio from the color oscillator clock, which is divided by 32 before being applied to counter #1s
clock input.
14,318,180 / 32 = 447,443 counter #1s clock frequency
447,443 / 8300 = 53.9
desired counts
The closest frequency obtainable would be :
447,443 / 54 = 8.286KHz closest frequency
Now, divide the 54 between the two counters (6 * 9 = 54):
task = 14; /* counter setup mode task */
params[0] = 1;
/* setup counter #1 */
params[1] = 2;
/* set counter #1 mode to 2 */
params[2] = 6;
/* set counter #1 count to 6 */
a12drv(FP_OFF(task),FP_OFF(params),FP_OFF(status)); /* call the driver */
task = 14; /* counter setup mode task */
params[0] = 0;
/* setup counter #2 */
params[1] = 2;
/* set counter #2 mode to 2 */
params[2] = 9;
/* set counter #2 count to 9 */
a12drv(FP_OFF(task),FP_OFF(params),FP_OFF(status)); /* call the driver */