Found the problem from your data. I have the bits of the byte numbered in reverse. Where I do a "BTFSS ADLOW,00" it should be bit 07 instead of 00. Bit 1 should be 06....and bit 7 is 00. And the same for all the bit tests of ADHIGH. I did do some limited testing on the program and thought it worked. For the fully untested code, I apologize.. The problem became apparent by looking for what hex values resulted in a display with 10 or 5 in it. hex 1F is 19.3, so it has both 10 and 5. hex 3E just has 5, hex 5D just has 10. 0001 1111 10 5 0011 1110 5 0101 1101 10 xxxx xxx1 bits only on when 10 xxxx xx1x bits only on when 5 So it looks like I am testing low order bit when should be testing high order bit.. Bill ----- Original Message ----- From: "Chetan Bhargava" To: "Microcontroller discussion list - Public." Sent: Wednesday, January 18, 2006 8:15 PM Subject: Re: [PIC] ADC code generator Replaced old code with Bill's code, reran the tests, got following results (exactly same as before). ADLOW Display 00 00.0 1F 19.3 3E 09.6 5D 14.5 7C 04.8 9B 16.9 BA 07.2 D9 12.1 FF 19.9 ADHIGH was 0x00 all the time. The three digits on the display were CDV01, CDV02, CDV03 The main calling procedure is: main: ;start the conversion call convert ;start the adc and get the result ;ADRES has the conversion result here movf ADRES,w ;we are trying the new sub from piclist CVDEC movlw 0xff movwf ADLOW movlw 0x00 movwf ADHIGH call CVDEC ;CVD1 - hundreds ;CVD2 - Tens ;CVD3 - Units movf CVD01,w movwf hundreds movf CVD02,w movwf tens movf CVD03,w movwf units ;movwf ACC0 ;--somewhat working procedure ;call divide ;testing binary_to_bcd by forcing bin below ;movlw d'200' ;call binary to BCD ;movf ACC0,w ;movwf bin ;call binary_to_BCD call display goto main ;repeat allover again Bill's code that was assembled is attached. -- Chetan Bhargava Web: http://www.bhargavaz.net Blog: http://microz.blogspot.com -------------------------------------------------------------------------------- > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist