22.1 Counter 0 – A/D Sample Rate Control

Counter 0 is a 24-bit, “divide-by-n” counter used for controlling the A/D sampling rate. The counter has a clock input, a gate input, and an output. The input is a 10MHz or 1MHz clock provided on the board and selected with bit CKFRQ0 in register Base+4, bit 5. The gate is an optional signal that can be input on pin 21 of I/O header J17 when DIOCTR (Base+11, bit 7) is 1. If DIOCTR=0, the counter runs freely. The output is a positive pulse whose frequency is equal to the input clock divided by the 24-bit divisor programmed into the counter. The output appears on pin 24 of the I/O header when DIOCTR is 1. If DIOCTR=0, the output is not accessible except as an A/D trigger.

The counter operates by counting down from the programmed divisor value. When the counter reaches a count of 1, it outputs a positive-going pulse equal to one input clock period (100ns or 1µs, depending on the input clock selected by FRQSEL0). On the next input clock, the counter then reloads to the initial load value and repeats the process indefinitely as long as it is enabled.

When AINTE=1 and ADCLK=0, the output can be used to trigger A/D conversions. If SCANEN=0, scan mode is disabled, and each clock pulse will cause the circuit to sample one A/D channel within the selected channel range. If SCANEN=1, scan mode is enabled, and each clock pulse will cause the circuit to sample each A/D channel within the selected channel range in quick succession.

The output frequency of counter 0 can range from 5MHz (10MHz clock, divisor = 2) to 0.06Hz (1MHz clock divided by 16,777,215, or 224 -1).The fastest speed supported by the A/D circuit is 100KHz, so the counter should not be programmed to generate pulses faster than 100KHz when in non-scan mode and 100KHz divided by the size of the scan range when in scan mode.

The control register at page 0 Base+15 is used to load and clear the counter and to enable and disable counting. The optional gate (when DIOCTR=1) can be enabled and disabled, and the counter value can be latched for reading.

Last updated