// ADC channel number definition # defineADC_Chanel0 (unsigned char) (0x00 <4) # defineADC_Chanel1 (unsigned char) (0x01 <4) # defineADC_Chanel2 (unsigned char) (0x02 <4) # defineADC_Chanel3 (unsigned char) (0x03 <4) # defineADC_Chanel4 (unsigned char) (0x04 <4) # defineADC_Chanel5 (unsigned char) (0x05 <4) # defineADC_Chanel6 (unsigned char) (0x06 <4) # defineADC_Chanel7 (unsigned char) (0x07 <4) # defineADC_Chanel8 (unsigned char) (0x08 <4 )//********** * ************************* // Function name: AdcSwitch // function: in single-channel mode, convert the AD value of a channel // entry parameter: The AD channel number to be converted // exit parameter: none //************************************* ** void AdcSwitch (uint8 Chanel) {uint8 Tmp = 0; Tmp = Chanel | 0x01; // select the channel to start the ADC conversion speed 16-byte ADCON = Tmp; while (ADCON & 0x08) = 0); ADCON & = ~ 0x08; // The conversion end sign is 0} // ---- instance application ------- void main (void) {while (1) {while (! F_10MS); F_10MS = 0; // AdcSwitch (ADC_Chanel1); g_ucTmp1 = ADDATAH; // extract the adconversion result // g_ucTmp2 = ADDATAL ;}}