Here is another way of aproaching the A/D based on some code Melanie posted a long time ago, this uses direct access to the pics registers instead of using PBP's routines:
By changing ADCON0 to different values you should be able to read analog in on all the other analog pinsCode:Analog_In: ANSEL=%00110001 ADCON0=%10000001; ' Enable ADC Module on pin AN0 PauseUS 50; ' 50uS Pause to allow sampling Capacitor to charge ADCON0.1=1 ' Start Conversion While ADCON0.1=1:Wend ' Wait for conversion to complete AnalogIn.Highbyte=ADRESH AnalogIn.Lowbyte=ADRESL ' Read 16-bit Result RETURN




Bookmarks