English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (516/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
22.4.12.1 Example: Using Dual 8-Word Buffers
To enable the dual 8-word buffers and alternating the
buffer fill, set the BUFM (AD1CON2<1>) bit. The BUFM
setting does not affect other operational parameters.
First, the conversion sequence starts filling the buffer at
ADC1BUF0 (buffer location 0 x 0). After the first inter-
rupt occurs, the buffer begins to fill at ADC1BUF8 (buf-
fer location 0 x 8). The BUFS (AD1CON2<7>) bit is
alternately set and cleared after each interrupt to show
which buffer is being filled. In this example, three ana-
log inputs are sampled and an interrupt occurs after
every third sample.
22.4.12.2 Example: Using Alternating MUX A,
MUX B Input Selections
Setting the ALTS (AD1CON2<0>) bit enables alternat-
ing input selections. The first sample uses the MUX A
inputs specified by the CH0SA (AD1CHS<19:16>) and
CH0NA (AD1CHS<23>) bits. The next sample uses the
MUX B inputs specified by the CH0SB
(AD1CHS<27:24>) and CH0NB (AD1CHS<31>) bits.
In the following example, one of the MUX B input
specifications uses 2 analog inputs as a differential
source to the sample/hold.
This example also demonstrates use of the dual 8-word
buffers. An interrupt occurs after every 4th sample,
which results in filling 4-words into the buffer on each
interrupt.
22.4.12.3 Example: Converting Three Analog
Inputs Using Alternating Sample
Mode and a Scan List
It is possible to sample by scanning through the input
channels and alternate between MUX A and MUX B.
When the Alternating Sample mode is selected, the
first input to be sampled will be the input selected for
MUX A, the second sample will be the input selected
for MUX B. Then the process repeats. When scanning
is combined with Alternating Input mode, the positive
input to MUX A is selected by the contents of the
AD1CSSL register, not CH0SA. For each sample that
MUX A is selected the next item in the scan list is sam-
pled. The positive input to MUX B is selected by
CH0SB (AD1CHS<27:24>).
When ASAM (AD1CON1<2>) is clear, sampling will not
resume after conversion completion, but will occur
when setting the SAMP (AD1CON1<1>) bit.
22.5 Initialization
A simple initialization code example for the ADC
module is provided in Example 22-5.
In this particular configuration, all 16 analog input pins,
AN0-AN15, are set up as analog inputs. Operation in
IDLE mode is disabled, output data is in unsigned frac-
tional format, and AVDD and AVSS are used for VR+ and
VR-. The start of acquisition, as well as start of conver-
sion (conversion trigger), are performed manually in
software. The CH0 SHA is used for conversions. Scan-
ning of inputs is disabled, and an interrupt occurs after
every acquisition/convert sequence (1 conversion
result). The ADC conversion clock is TPB/2.
Since acquisition is started manually by setting the
SAMP bit (AD1CON1<1>) after each conversion is
complete, the auto-sample time bits, SAMC<4:0>
(AD1CON3<12:8>), are ignored. Moreover, since the
start of conversion (i.e., end of acquisition) is also trig-
gered manually, the SAMP bit needs to be cleared
each time a new sample needs to be converted.
DS61143E-page 514
Preliminary
© 2008 Microchip Technology Inc.