59 u8_wdtState = _SWDTEN;
64 _SWDTEN = u8_wdtState;
88 if (u8_autoSampleTime > 31) u8_autoSampleTime=31;
92 AD1CON1 = ADC_CLK_AUTO | ADC_AUTO_SAMPLING_OFF;
95 AD1CON1bits.AD12B = 1;
97 AD1CON1bits.AD12B = 0;
99 AD1CON3 = ADC_CONV_CLK_INTERNAL_RC | (u8_autoSampleTime<<8);
100 AD1CON2 = ADC_VREF_AVDD_AVSS;
101 #if (defined(__PIC24H__)|| defined(__dsPIC33F__) || defined(__PIC24E__)|| defined(__dsPIC33E__))
102 AD1CHS0 = ADC_CH0_NEG_SAMPLEA_VREFN | u16_ch0PositiveMask;
104 AD1CHS = ADC_CH0_NEG_SAMPLEA_VREFN | u16_ch0PositiveMask;
106 AD1CON1bits.ADON = 1;
139 for (u8_i=0; u8_i<16; u8_i++) {
140 if (u16_ch0ScanMask & u16_mask)
145 if (u8_autoSampleTime > 31) u8_autoSampleTime=31;
147 AD1CON1bits.ADON = 0;
149 AD1CON1 = ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON;
152 AD1CON1bits.AD12B = 1;
154 AD1CON1bits.AD12B = 0;
156 AD1CON3 = ADC_CONV_CLK_INTERNAL_RC | (u8_autoSampleTime<<8);
157 AD1CON2 = ADC_VREF_AVDD_AVSS | ADC_CONVERT_CH0 | ADC_SCAN_ON | ((u8_nChannels-1)<<2);
158 #if (defined(__PIC24H__)|| defined(__dsPIC33F__) || defined(__PIC24E__)|| defined(__dsPIC33E__))
159 AD1CHS0 = ADC_CH0_NEG_SAMPLEA_VREFN;
161 AD1CHS = ADC_CH0_NEG_SAMPLEA_VREFN;
163 AD1CSSL = u16_ch0ScanMask;
169 AD1CON1bits.ADON = 1;
204 for (u8_i=0; u8_i<16; u8_i++) {
205 if (u16_ch0ScanMask & u16_mask)
210 if (u8_autoSampleTime > 31) u8_autoSampleTime=31;
212 AD1CON1bits.ADON = 0;
214 AD1CON1 = ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON;
217 AD1CON1bits.AD12B = 1;
219 AD1CON1bits.AD12B = 0;
221 AD1CON3 = ADC_CONV_CLK_INTERNAL_RC | (u8_autoSampleTime<<8);
222 AD1CON2 = ADC_VREF_AVDD_AVSS | ADC_CONVERT_CH0 | ADC_ALT_BUF_ON | ADC_SCAN_ON | ((u8_nChannels-1)<<2);
223 #if (defined(__PIC24H__)|| defined(__dsPIC33F__) || defined(__PIC24E__)|| defined(__dsPIC33E__))
224 AD1CHS0 = ADC_CH0_NEG_SAMPLEA_VREFN;
226 AD1CHS = ADC_CH0_NEG_SAMPLEA_VREFN;
228 AD1CSSL = u16_ch0ScanMask;
234 AD1CON1bits.ADON = 1;
273 AD1CON1bits.ADON = 0;
275 AD1CON1 = ADC_CLK_TMR | ADC_SAMPLE_SIMULTANEOUS;
276 AD1CON3 = (u16_numTcyMask & 0x00FF);
277 AD1CON2 = ADC_VREF_AVDD_AVSS | ADC_CONVERT_CH0123 | ADC_ALT_BUF_ON;
278 #if (defined(__PIC24H__)|| defined(__dsPIC33F__) || defined(__PIC24E__)|| defined(__dsPIC33E__))
279 AD1CHS0 = ADC_CH0_NEG_SAMPLEA_VREFN | (u8_ch0Select & 0x1F);
280 AD1CHS123 = u16_ch123SelectMask;
282 AD1CHS = ADC_CH0_NEG_SAMPLEA_VREFN | (u8_ch0Select & 0x1F);
290 AD1CON1bits.ADON = 1;