Another issue regarding the 16F688.
Setting up the 10-bit ADC I expected a 0 – 1023 range, what I got was 0 to 65472 !!?
Of cause I made some kind of mistake here but nothing that is obvious to me. Also I have a problem with the right justify and getting the decimal point and scaling (Volts) correct. I have tried a few ways to solve it but I’m having trouble to understand the math. Can somebody explain how to do it correctly?

Thanks guys!




Code:
 

OSCCON = %1110111           	'Use Internal OSC at 8MHz
CMCON0 = %0000111          	'Comparators off
TRISA =  %000100               	'PortA 0=output- 1=input
TRISC =  %000000                	'PortC 0=output- 1=input
ANSEL =  %0000100            	 '(Analog Select) 0=Digital 1=Analog

V VAR WORD
L VAR WORD
T VAR WORD

DEFINE ADC_BITS 10          	' 10-bits
DEFINE ADC_CLOCK 3          	' rc
DEFINE ADC_SAMPLEUS 50      	' Sample time uS

ADCON0 = %00000001          	' ADC in operation
ADCON1 = %11001000         	' rightadjust and Vref+

GOSUB movelcd

PAUSE 500

loop:

GOSUB readv

PAUSE 50

GOTO loop

END

'****************** - SUBS - ************************************
MOVELCD:

DEFINE LCD_DREG  PORTC          	'Data on PORTC PIN 10,9,8,7          
DEFINE LCD_DBIT    0            	'Start bit for PORTC
DEFINE LCD_RSREG PORTC          	'Register Select (RS) 
DEFINE LCD_RSBIT   4            	'RS bit PORTC PIN 6
DEFINE LCD_EREG  PORTC          	'Enable Port PORTC 
DEFINE LCD_EBIT    5            	'E bit PORTC PIN 5
DEFINE LCD_BITS    4            	'bitmode (4-bit)
DEFINE LCD_LINES   2            	'number of lines (2)

PAUSE 500

RETURN
'****************************************************************
readv:

ADCIN 2,V                       ' take reading

T = V
                                     
LCDOUT $FE,2,"ADC ", DEC T,"    "

lCDOUT $FE,$C0,"DCV = ",DEC (V/100),".",dec2 V," "

RETURN