If your value goes to zero, there is something more wrong than a little noise. I have found some chips that don't work properly with ADCIN (18F2221 for example).
Try the following:
Code:
Result = 0
Channel = 1 ; Whichever
Channel = Channel << 3 ; offset the bits
ADCON0 = %11000001 | Channel ; OR the channel into the reg.
For X = 0 to 9
PAUSEUS 10
ADCON0.2 = 1 ; Start conversion
PAUSEUS 2 ; Guarantee min time
WHILE ADCON0.2:WEND ; Wait until done
Result = Result + ADRES
Next X
Result = Result/10
Result is, of course, a WORD var
Bookmarks