Adam, I haven't gone through your code but check your ADCON1 settings. Use the chip datasheet as a reference and NOT the Microchip Mid-range Reference manual. The A/D bits for selecting right/left justification are wrong in that doccument. Cheers, Andrew ________________________________________________ Get your own "800" number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag ---- On , Adam Cooper (adam@PULSARINFORMATICS.COM) wrote: > Hi, > > When I do an A/D conversion I get funny results. If I use right > justified, > ADFM = 1 and try and read 5V... I get something like (011- 1000111). > However as soon as I switch to left justified, ADFM = 0, I get all 1's > (16 > of them)... including the extra 6 bits that should be set to 0.. > (11111111-11111111) - should be (1111111-111000000) > > Any Ideas / Help? > > > bsf STATUS, RP0 ; Select bank 1 > movlw 0x0FF ; RA5-0 inputs, > movwf TRISA > movlw 0x02 ; set all of port E > movwf ADCON1 ; to Digital I/O, port A to analog > clrf STATUS ; select bank 0 > movlw B'11000001' ;RC osc [7-6], A/D ch0 [5-3], a/d on [0] > movwf ADCON0 > ; need to wait the proper > acquisition time ~20us > ; 20us = overhead + (loop time > * > loop count) > ; 20us = 2us + (3us * loop > count) > ; loop count = 6 > > ADStart: > movlw 0x06 ; 1 us > movwf DELAY ; 1 us > > ADConv_Acquisition: ; ----loop----- > decfsz DELAY, f ; 1 us - > goto ADConv_Acquisition ; 2 us - > ; ---- loop----- > > > banksel ADCON0 ; additional 2 us... padding > bsf ADCON0, GO > > > btfss ADCON0, GO > goto ADReady > goto $-2 > > > ADReady... just displays the value and goto's ADStart > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body