This reply is how I read the ADC in a 16F876A. I guess the registers and the reading would be the same in the 16F676, but I haven't read the datasheet and can't vouch for it.
Code:
Scanspeed var word ' this is where we read the ADC value
ADCON0.2 = 1 ' Start conversion
while ADCON0.2 ' wait till conversion is done
wend
ScanSpeed.HighByte = ADRESH
ScanSpeed.LowByte = ADRESL
Also, you need to heed this warning (from the PBP manual)
Code:
Before ADCIN can be used, the appropriate TRIS register must be set to
make the desired pins inputs. ADCON1 also needs to be set to assign
the desired pins to analog inputs and in some cases to set the result
format and clock source.
Hope this helps
Jerson
Bookmarks