I think that the code "adcin3x" is for the old pic16F877, not a pic16f887. The adc in the newer chips have more registers. I have found the adcin command does not always work. So I use a manual set and read routine. Below is an example for 10bit, I think the 8bit result will be in the ADC_AN0.HIGHBYTE when the adc is set to left shift?
Code:
ADC_AN0 var WORD '10bit result
ADC_AN1 var WORD '10bit result
'Read AN0
'--------------------------------------------------------------------------
ADCON0 = %11000011 'Set adc channel = AN0
WHILE ADCON0.1 = 1 'WAIT FOR CONVERSION
WEND
ADC_AN0.HIGHBYTE = ADRESH
ADC_AN0.LOWBYTE = ADRESL
'Read AN1
'--------------------------------------------------------------------------
ADCON0 = %11000111 'Set adc channel = AN1
While ADCON0.1 = 1 'WAIT FOR CONVERSION
WEND
ADC_AN1.HIGHBYTE = ADRESH
ADC_AN1.LOWBYTE = ADRESL
'---------------------------------------------------------------------------
Bookmarks