Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
PIC24F Family Reference Manual
DS39737A-page 49-30 Preliminary © 2010 Microchip Technology Inc.
49.6.3 Channel Scanning
The ADC module supports the Channel Scan mode using CH0 (S&H Channel 0). The number
of inputs scanned is software-selectable. Any subset of the analog inputs from AN0 to AN5 can
be selected for conversion. The selected inputs are converted in ascending order. For example,
if the input selection includes AN4, AN1 and AN3, the conversion sequence is AN1, AN3 and
AN4. The conversion sequence selection is made by programming the Channel Select register
(AD1CSSL). A logic ‘1’ in the Channel Select register marks the associated analog input channel
for inclusion in the conversion sequence. The Channel Scanning mode is enabled by setting the
Channel Scan bit (CSCNA) in the ADC Control Register 2 (ADxCON2<10>). In Channel Scan
mode, MUXA software control is ignored and the ADC module sequences through the enabled
channels.
For every sample/convert sequence, one analog input is scanned. The ADC interrupt must be
generated after all selected channels are scanned. If “N” inputs are enabled for channel scan, an
interrupt must be generated after an “N” sample/convert sequence. Table 49-11 lists the SMPI
values to scan “N” analog inputs using CH0 in different ADC configurations.
Table 49-11: Conversions Per Interrupt in Channel Scan Mode
Example 49-6 shows the code sequence to scan four analog inputs using CH0. Figure 49-16
illustrates the ADC operation sequence.
Example 49-6: Code Sequence to Scan Four Analog Inputs Using CH0
CHPS<1:0> SIMSAM
SMPI<3:0>
(Decimal)
Conversions/
Interrupt
Description
00 x N-1 N 1-Channel mode
01 0 2N-1 2N 2-Channel Sequential Sampling
mode
1x 0 4N-1 4N 4-Channel Sequential Sampling
mode
01 1 N-1 2N 2-Channel Simultaneous Sampling
mode
1x 1 N-1 4N 4-Channel Simultaneous Sampling
mode
Note: On ADC Interrupt, the ADC internal logic is initialized to restart the conversion
sequence from the beginning.
AD1CON2bits.SMPI = 3; // Select 4 conversions between interrupt
AD1CHS0bits.ASAM = 1; // Enable Automatic Sampling
AD1CON2bits.CSCNA = 1; // Enable Channel Scanning
// Initialize Channel Scan Selection
AD1CSSLbits.CSS2=1; // Enable AN2 for scan
AD1CSSLbits.CSS3=1; // Enable AN3 for scan
AD1CSSLbits.CSS4=1; // Enable AN4 for scan
AD1CSSLbits.CSS5=1; // Enable AN5 for scan
Protego_Release_01_05-Related-OEM-Documentation-PIC24FJ32MC10X-Reference_Manual-Section49-10-Bit_ADC_with_4_Simultaneous_Conversions.pdf