1
Web platform / Analog Input
AD1PCFGL = 0xFFFF; //digital pins
AD1PCFGLbits.PCFG2 = 0;
AD1PCFGLbits.PCFG3 = 0;
AD1CON1bits.FORM = 3; // Data Output Format: Signed Fraction (Q15 format)
AD1CON1bits.SSRC = 2; // Sample Clock Source: GP Timer starts conversion
AD1CON1bits.ASAM = 1; // ADC Sample Control: Sampling begins immediately after conversion
AD1CON1bits.AD12B = 0; // 12-bit ADC operation turned off
AD1CON3bits.ADRC = 0; // ADC Clock is derived from Systems Clock
AD1CON3bits.ADCS = 63;
AD1CON2bits.CHPS = 1; // Converts CH0
//AD1CHS0bits.CH0SA=2; // MUXA +ve input selection (AN5) for CH0
AD1CHS0bits.CH0NA=0; // MUXA -ve input selection (Vref-) for CH0
IFS0bits.AD1IF = 0; // Clear the A/D interrupt flag bit
IEC0bits.AD1IE = 0; // Do Not Enable A/D interrupt
AD1CON1bits.ADON = 1;
Thanks in advance.