57 #ifndef BUILT_ON_ESOS // Excluded from ESOS builds due to a busy loop 62 u8_wdtState = _SWDTEN;
67 _SWDTEN = u8_wdtState;
92 if (u8_autoSampleTime > 31) u8_autoSampleTime=31;
96 AD1CON1 = ADC_CLK_AUTO | ADC_AUTO_SAMPLING_OFF;
99 AD1CON1bits.AD12B = 1;
101 AD1CON1bits.AD12B = 0;
106 AD1CON3 = ADC_CONV_CLK_INTERNAL_RC | (u8_autoSampleTime<<8);
108 #if (HARDWARE_PLATFORM == EMBEDDED_C1) 109 AD1CON2 = ADC_VREF_AVDD_EXT;
111 AD1CON2 = ADC_VREF_AVDD_AVSS;
114 #if (defined(__PIC24H__)|| defined(__dsPIC33F__) || defined(__PIC24E__)|| defined(__dsPIC33E__)) 115 AD1CHS0 = ADC_CH0_NEG_SAMPLEA_VREFN | u16_ch0PositiveMask;
117 AD1CHS = ADC_CH0_NEG_SAMPLEA_VREFN | u16_ch0PositiveMask;
119 AD1CON1bits.ADON = 1;
149 uint16_t u16_mask = 0x0001;
152 for (u8_i=0; u8_i<16; u8_i++) {
153 if (u16_ch0ScanMask & u16_mask)
158 if (u8_autoSampleTime > 31) u8_autoSampleTime=31;
160 AD1CON1bits.ADON = 0;
162 AD1CON1 = ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON;
165 AD1CON1bits.AD12B = 1;
167 AD1CON1bits.AD12B = 0;
172 AD1CON3 = ADC_CONV_CLK_INTERNAL_RC | (u8_autoSampleTime<<8);
173 AD1CON2 = ADC_VREF_AVDD_AVSS | ADC_CONVERT_CH0 | ADC_SCAN_ON | ((u8_nChannels-1)<<2);
174 #if (defined(__PIC24H__)|| defined(__dsPIC33F__) || defined(__PIC24E__)|| defined(__dsPIC33E__)) 175 AD1CHS0 = ADC_CH0_NEG_SAMPLEA_VREFN;
177 AD1CHS = ADC_CH0_NEG_SAMPLEA_VREFN;
179 AD1CSSL = u16_ch0ScanMask;
185 AD1CON1bits.ADON = 1;
217 uint16_t u16_mask = 0x0001;
220 for (u8_i=0; u8_i<16; u8_i++) {
221 if (u16_ch0ScanMask & u16_mask)
226 if (u8_autoSampleTime > 31) u8_autoSampleTime=31;
228 AD1CON1bits.ADON = 0;
230 AD1CON1 = ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON;
233 AD1CON1bits.AD12B = 1;
235 AD1CON1bits.AD12B = 0;
240 AD1CON3 = ADC_CONV_CLK_INTERNAL_RC | (u8_autoSampleTime<<8);
241 AD1CON2 = ADC_VREF_AVDD_AVSS | ADC_CONVERT_CH0 | ADC_ALT_BUF_ON | ADC_SCAN_ON | ((u8_nChannels-1)<<2);
242 #if (defined(__PIC24H__)|| defined(__dsPIC33F__) || defined(__PIC24E__)|| defined(__dsPIC33E__)) 243 AD1CHS0 = ADC_CH0_NEG_SAMPLEA_VREFN;
245 AD1CHS = ADC_CH0_NEG_SAMPLEA_VREFN;
247 AD1CSSL = u16_ch0ScanMask;
253 AD1CON1bits.ADON = 1;
289 uint16_t u16_ch123SelectMask,
290 uint16_t u16_numTcyMask ) {
292 AD1CON1bits.ADON = 0;
294 AD1CON1 = ADC_CLK_TMR | ADC_SAMPLE_SIMULTANEOUS;
295 AD1CON3 = (u16_numTcyMask & 0x00FF);
296 AD1CON2 = ADC_VREF_AVDD_AVSS | ADC_CONVERT_CH0123 | ADC_ALT_BUF_ON;
297 #if (defined(__PIC24H__)|| defined(__dsPIC33F__) || defined(__PIC24E__)|| defined(__dsPIC33E__)) 298 AD1CHS0 = ADC_CH0_NEG_SAMPLEA_VREFN | (u8_ch0Select & 0x1F);
299 AD1CHS123 = u16_ch123SelectMask;
301 AD1CHS = ADC_CH0_NEG_SAMPLEA_VREFN | (u8_ch0Select & 0x1F);
303 ASSERT(u16_ch123SelectMask == 0);
311 AD1CON1bits.ADON = 1;
void configADC1_AutoScanIrqCH0(uint16_t u16_ch0ScanMask, uint8_t u8_autoSampleTime, uint8_t u8_use12bit)
void configADC1_ManualCH0(uint16_t u16_ch0PositiveMask, uint8_t u8_autoSampleTime, uint8_t u8_use12bit)
uint16_t convertADC1(void)
void configADC1_Simul4ChanIrq(uint8_t u8_ch0Select, uint16_t u16_ch123SelectMask, uint16_t u16_numTcyMask)
static void WAIT_UNTIL_CONVERSION_COMPLETE_ADC1()
_PERSISTENT const char * sz_lastTimeoutError
void configADC1_AutoHalfScanIrqCH0(uint16_t u16_ch0ScanMask, uint8_t u8_autoSampleTime, uint8_t u8_use12bit)
unsigned char uint8_t
An abbreviation for an 8-bit unsigned integer.
#define NOP()
Insert a one-cycle nop instruction.