Adam wrote: >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 You do realise that ADRESL & ADRESH are in different banks don't you? (ADRESH is in bank 0 and ADRESL is in bank 1) Regards... -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body