© 2004 Microchip Technology Inc. DS70065C-page 18-11
Section 18. 12-bit A/D Converter
12-bit A/D
Converter
18
The start time for sampling can be controlled in software by setting the SAMP control bit. The
start of the sampling time can also be controlled automatically by the hardware. When the A/D
converter operates in the Auto Sample mode, the S/H amplifier(s) is reconnected to the analog
input pin at the end of the conversion in the sample/convert sequence. The auto sample function
is controlled by the ASAM control bit.
The conversion trigger source ends the sampling time and begins an A/D conversion or a
sample/convert sequence. The conversion trigger source is selected by the SSRC control bits.
The conversion trigger can be taken from a variety of hardware sources or can be controlled
manually in software by clearing the SAMP control bit. One of the conversion trigger sources is
an auto conversion. The time between auto conversions is set by a counter and the A/D clock.
The Auto Sample mode and auto conversion trigger can be used together to provide endless
automatic conversions without software intervention.
An interrupt may be generated at the end of each sample/convert sequence or multiple
sample/convert sequences, as determined by the value of the SMPI control bits. The number of
sample/convert sequences between interrupts can vary between 1 and 16.
18.5 A/D Module Configuration
The following steps should be followed for performing an A/D conversion:
1. Configure the A/D module
• Select voltage reference source to match expected range on analog inputs
• Select the analog conversion clock to match desired data rate with processor clock
• Determine how sampling will occur
• Determine how inputs will be allocated to the S/H channel
• Select how conversion results are presented in the buffer
• Select interrupt rate
• Turn on A/D module
2. Configure A/D interrupt (if required)
• Clear ADIF bit
• Select A/D interrupt priority
The options for each configuration step are described in the subsequent sections.
18.6 Selecting the Voltage Reference Source
The voltage references for A/D conversions are selected using the VCFG<2:0> control bits
(ADCON2<15:13>). The upper voltage reference (V
REFH) and the lower voltage reference
(V
REFL) may be the internal AVDD and AVSS voltage rails or the VREF+ and VREF- input pins.
The external voltage reference pins may be shared with the AN0 and AN1 inputs on low pin count
devices. The A/D converter can still perform conversions on these pins when they are shared
with the V
REF+ and VREF- input pins.
The voltages applied to the external reference pins must meet certain specifications. Refer to the
“Electrical Specifications” section of the device data sheet for further details.
Note: The SSRC<2:0>, SIMSAM, ASAM, CHPS<1:0>, SMPI<3:0>, BUFM and ALTS bits,
as well as the ADCON3 and ADCSSL registers, should not be written to while
ADON = 1. This would lead to indeterminate results.