I'm not sure if this is the problem, but try:
ADCON2.7=1
I'm not sure if this is the problem, but try:
ADCON2.7=1
"I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams
I never had any luck with DEFINE ADC_BITS 8 it allways wanted to work in 10 bit. But if you only need 8 bit, do an ADCIN with DEFINE_BITS 10 to a word variable then divide the answere by 4.
Try a WORD size variable.where STORE_0 is a byte sized variable, and it works perfet.
Now I tryed to perform a 10 bit conversion, I used a word sized variable and the define was modified in:
DEFINE ADC_BITS 10
...but it store again one value large one byte, no more...
Dave
Always wear safety glasses while programming.
This is for a different chip but it might help. I like dealing with the registers directly, an example of both are here.
http://www.picbasic.co.uk/forum/show...9694#post79694
Dave
Always wear safety glasses while programming.
This works for 10-bit A/D on an 18F2520, using 9600 baud serial to a PC to view the results.
Code:DEFINE OSC 40 SerPin VAR PORTC.6 DEFINE ADC_BITS 10 ; 10-bit results ADCON2.7 = 1 ; right justify ADval VAR WORD Main: ADCIN 0, ADval SEROUT2 SerPin, 84,[DEC ADval,13,10] PAUSE 500 GOTO Main
DT
Bookmarks