unsigned int ReadADC(unsigned char channel){
unsigned int value;
//read the ADCH will permet updata
ADCON0 = 0x81; //Right justified,and enable the ADC
ADCON1 = 0x50; //set the ADC clock to 1/8 FOSC
ADCON0|= (channel<<2); //Switch to the select adc channel
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
NOP();
GO_DONE=1;
NOP();
NOP();
while(GO_DONE); //wait for ADC complete
NOP();
value=ADRESH; //Only work on 8bit mode
value<<=8;
value+=ADRESL; //Disable the adc and clear the ADCIF(write 1 to ADCIF)