I'm trying to use adcin to read two different pots to get 8 bit results and I'm having trouble. I'm using the internal oscillator (there is no external oscillator). The pots are connected to AN0 and AN1
' Define ADCIN parameters ********************************
Define ADC_BITS 8 ' Set number of bits in result
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
'Define ADC_CLOCK 3 ' This define is inoperative on 16F88x
ADCON0 = %11000000 ' Set ADC_CLOCK to RC (DEFINE ACD_CLOCK inoperative on the 16F88x)
ADCON1 = %00000000 ' Left-Justify result in ADRESH:ADRESL registers
ANSEL = %00000011 ' Set AN0, AN1 to analog, others digital
ANSELH = %00000000 ' Set AN8 and higher channels to digital operation
'************************************************* *********
I just copied the code from the LAB-X1 "adcin3x" sample program for the 16F887. I figured it would work the same for the 16F886 since it's basically a 28 pin version of the 16F887, but it doesn't seem to be working. I figured the problem was that the LAB-X1 uses a 4MHz external oscillator, but I've tried different setting on ADCON0 and it doesn't seem to change anything.
Bookmarks