if(prevCh!=3)
{
rADCCON = (1<<14)|(preScaler<<6)|(3<<3); //setup channel
for(i=0;i<1000;i++); //delay to set up the next channel
prevCh=3;
}
rADCCON|=0x1; //start ADC
while(rADCCON & 0x1); //check if Enable_start is low
while(!(rADCCON & 0x8000)); //check if EC(End of Conversion) flag is high