void ADC_Init(void){
unsigned char val=0;
ADCON1bits.FORM = 0x0;//signed fractional format
ADCON1bits.SSRC = 0x7;//enable auto convert option
ADCON1bits.ASAM = 0x1;//enable automatic sampling
ADCON1bits.SIMSAM = 0;//enabble sequential sampling
ADCON2bits.SMPI = 0x01;//Interrupts at the completion of conversion for each 2nd sample/convert sequence
ADCON2bits.CHPS = 0x01;//sample on 2 S/H channels - CH0 and CH1
ADCON3bits.SAMC = 0;//no Tad between start of sampling and start of conversion
val = (unsigned char)(ADCS_VAL + 0.5);//Here 0.5 is added to get the rounding number
ADCON3bits.ADCS = val;//configure A/D clock period
ADCHS = 0x0023;//Set up A/D Channel Select Register to convert AN3 on Mux A input of CH0 and CH1 S/H amplifiers
ADCSSL = 0x0000;//Channel Scanning is disabled. All bits left to their default state
ADPCFG = 0xFFFF;
TRISB |= (1<<3);//To set up AN3 as input
ADPCFGbits.PCFG3 = 0;//Set up channels AN3 as analog input and configure rest as digital
IFS0bits.ADIF = 0;//Clear the A/D interrupt flag bit
IEC0bits.ADIE = 1;//Set the A/D interrupt enable bit
ADCON1bits.ADON = 1;//Turn on the A/D converter
}