English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (512/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
22.4.5 TERMINATE CONVERSION
SEQUENCE AFTER AN INTERRUPT
The CLRASAM bit provides a method to terminate
auto-sample after the first sequence is completed. Set-
ting the CLRASAM and starting an auto-sample
sequence will cause the A/D converter to complete one
auto-sample sequence (the number of samples as
defined by SMPI<3:0> (AD1CON2<5:2>)). Hardware
will clear ASAM (AD1CON1<2>) and set the interrupt
flag. This will stop the sampling process to allow
inspection of the result buffer without results being
overwritten by the next automatic conversion
sequence. The CLRASAM must be cleared by software
to disable this mode.
Note:
Disabling interrupts or masking the ADC
interrupt has no effect on the operation
of the CLRASAM bit.
22.4.6 CONVERSION SEQUENCE
EXAMPLES
The following configuration examples show the ADC
operation in different sampling and buffering configura-
tions. In each example, setting the ASAM bit starts
automatic sampling. A conversion trigger ends sam-
pling and starts conversion.
22.4.7 MANUAL CONVERSION CONTROL
When SSRC<2:0> = 000, the conversion trigger is
under software control. Clearing the SAMP bit
(AD1CON1<1>) starts the conversion sequence. See
Example 22-1 for sample code to manually control the
sampling of a single channel.
EXAMPLE 22-1: CONVERTING 1 CHANNEL, MANUAL SAMPLE START, MANUAL CONVERSION
START CODE
AD1PCFG = ~(1 << 5);
AD1CON1 = 0x0000;
// and starts converting
AD1CHS = 5 << 16;
AD1CSSL = 0;
AD1CON3 = 0x0002;
AD1CON2 = 0;
AD1CON1SET = 0x8000;
while (1) // repeat continuously
{
AD1CON1SET = 0x0002;
DelayNmSec(100);
AD1CON1CLR = 0x0002;
while (!(AD1CON1 & 0x0001));
ADCValue = ADC1BUF0;
}
// PORTB = Digital; RB5 = analog
// SAMP bit = 0 ends sampling ...
// Connect RB5/AN5 as CH0 input ..
// Manual Sample, Tad = 6 TPB
// turn ADC ON
// start sampling ...
// for 100 mS
// start Converting
// conversion done?
// yes then get ADC value
DS61143E-page 510
Preliminary
© 2008 Microchip Technology Inc.