Datasheet

2011-2013 Microchip Technology Inc. DS39995D-page 209
PIC24FV32KA304 FAMILY
To perform an A/D conversion:
1. Configure the A/D module:
a) Configure the port pins as analog inputs
and/or select band gap reference inputs
(ANS<12:10>, ANS<5:0>).
b) Select voltage reference source to match
the expected range on the analog inputs
(AD1CON2<15:13>).
c) Select the analog conversion clock to
match the desired data rate with the
processor clock (AD1CON3<7:0>).
d) Select the appropriate sample/conver-
sion sequence (AD1CON1<7:4> and
AD1CON3<12:8>).
e) Select how conversion results are
presented in the buffer (AD1CON1<9:8>).
f) Select the interrupt rate (AD1CON2<6:2>).
g) Turn on the A/D module (AD1CON1<15>).
2. Configure the A/D interrupt (if required):
a) Clear the AD1IF bit.
b) Select the A/D interrupt priority.
To perform an A/D sample and conversion using
Threshold Detect scanning:
1. Configure the A/D module:
a) Configure the port pins as analog inputs
(ANS<12:10>, ANS<5,0>).
b) Select the voltage reference source to
match the expected range on the analog
inputs (AD1CON2<15:13>).
c) Select the analog conversion clock to
match the desired data rate with the
processor clock (AD1CON3<7:0>).
d) Select the appropriate sample/conversion
sequence (AD1CON1<7:4>, AD1CON3<12:8>).
e) Select how the conversion results are
presented in the buffer (AD1CON1<9:8>).
f) Select the interrupt rate (AD1CON2<6:2>).
2. Configure the threshold compare channels:
a) Enable auto-scan – ASEN bit (AD1CON5<15>).
b) Select the Compare mode, “Greater Than,
Less Than or Windowed” – CMx bits
(AD1CON5<1:0>).
c) Select the threshold compare channels to
be scanned (ADCSSH, ADCSSL).
d) If the CTMU is required as a current
source for a threshold compare channel,
enable the corresponding CTMU channel
(ADCCTMUENH, ADCCTMUENL).
e) Write the threshold values into the
corresponding ADC1BUFn registers.
f) Turn on the A/D module (AD1CON1<15>).
3. Configure the A/D interrupt (OPTIONAL):
a) Clear the AD1IF bit.
b) Select the A/D interrupt priority.
Note: If performing an A/D sample and
conversion using Threshold Detect in Sleep
Mode, the RC A/D clock source must be
selected before entering into Sleep mode.