adc_clock

ADC block configuration

Author Rob Hamerling , Copyright © 2010, all rights reserved.
Adapted-by Rob Hamerling (clear ACQT bits)
Compiler 2.4n

Description

This library provides a procedure to configure ADC clock
according to ADC constraints about Tad values and PIC's clock speed
.
Selecting the appropriate ADC clocking is critical.
Not all PICs have the same min/max values for Tad.
See the ADC-chapter in the datasheet for the actual limits.
Some PICs can go faster than 20MHz, like 18F. LF-PICs don't follow
the same rules as the F-PICS (see 18F4550 and 18LF4550 for instance).
How to obtain a general rule of thumb? For some popular PICs we find:
For 16F88, and for many other PICs: 1.6 < Tad < 6.4 (microseconds)
For 18F4550 (and other 18F PICs):   0.8 < Tad < 25  (microseconds)
.
The ADC libraries use 2 constants as minimum and maximum Tad values.
The constants should contain a value 10 times as large as these
limits expressed in microseconds.
The following values are used by the library as defaults:
.
for 18F family:     ADC_MIN_TAD = 8      (0.8 us)
                    ADC_MAX_TAD = 250    (25 us)
.
for other PICs:     ADC_MIN_TAD = 16     (1.6 us)
                    ADC_MAX_TAD = 250    (16  us)
.
When these values are not acceptable alternate values may be specified
by the user  *** before *** including the ADC library.
.
The library will select the shortest possible Tad.
A warning will be issued when it is not possible to derive a value
for Tad within the limits of ADC_TAD_MIN and ADC_TAD_MAX with the
current clock speed. In that case the internal RC oscillator of the
ADC module will be selected automatically (Frc). When this is not
desired alternate values for ADC_TAD_MIN and/or ADC_TAD_MAX must be
specified, or an alternate clock speed must be used.


Notes

- This is a rewrite of a previous version of this library.
       - The device files contain a constant ADC_ADCS_BITCOUNT to
         indicate the number of bits of the ADCS variable of 'this' PIC.
         Clock devider selection bits (ADCS) can bit*2 or bit*3 or none.
           - when bit*2: divisor is 2, 8 or 32
           - when bit*3: divisor is 2, 4, 8, 16, 32 or 64
         ADCS bits may be scattered over different registers. When this is
         the case the device file contains a pseudo-variable ADCON0_ADCS
         to hide the scattering.
         Some PICs with ADC module have no ADCS bits at all (10F220/220)!


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private

Functions


Related samples

No sample found