i use RB0 as vref
RB1 as AN1
RB2 as AN2
this is my code... the problem is nothing happen...
unsigned char read_adc(void)
{
ADPCFG = 0x01FF; //10th channel is sampled and coverted
ADCON1 = 0x0004; //ADC off, output_format=INTEGER
//Manual start of convesion
//Automatic start of sampling after coversion
ADCHS = 0x0001; //Connect RB10 on AN10 as CH0 input
ADCSSL = 0; //No scan
ADCON3 = 0x1003; //ADCS=3 (min TAD for 10MHz is 3*TCY=300ns)
ADCON2 = 0x2000; //Interrupt upon completion of one sample/convert
ADCON1bits.ADON = 1; //ADC on
ADCON1bits.SAMP = 1;
delay_ms(100); //Wait for 100ms (sampling ...)
ADCON1bits.SAMP = 0; //Clear SAMP bit (trigger conversion)
while(ADCON1bits.DONE == 0);
return ADCBUF0;
}