Just some minor tips... If you'd like more people to read your post, you realy should make sure that you posts are easy to read. Line up the code. Don't put instructions in col 1 (it's not like that i your original code, is it ?). That part with the FALSE/TRUE/GOTO realy should have been cleaned up before beeing posted ! It could also help to see all relevant info, such as the setup code for the ADC in this case. And writing code using the builtin symbols provided by the Microship include files helps a lot, such as writing "btfss status, C" instead of "btfss status, 0". This way, we don't have to open the data sheet to look up if bit 0 realy is the "C" bit. Now, even if no one has seen anything yet, you can be more or less 100% sure that *something* is wrong there. Cleaning up the code and using symbols, could get you a fair bit closer to find it. Jan-Erik. PS. Finely, putting the first letter in each sentence in upper case, makes the text easier to read, and also shows that you care about those rading it (not saying that you do *not*, but it never hurts to show it also...) -----Original Message----- From: Jeffrey Vitale [mailto:jvitale@CNRIT.TAMU.EDU] Sent: den 16 oktober 2003 22:13 To: PICLIST@MITVMA.MIT.EDU Subject: [PIC]: a2d problems with 16f877a I am able to get an a2d value from my 877 chip reding value from a potentiometer connected to chip (using chips vdd as vref). after i put the value's from ADRESH into a user register (via W of course) i perform an ADDWF where W=D'55' to see whether or not the A2d value is greater than 200 or not (this is my threshold level i am interested in). the strange thing is that the STATUS carry bit (bit 0) does not stay at 1 like it should when the user register is 201 and greater. using leds, i am able to verify that the status bit will only show a MSB carry when the user register is of the following values: 201 through 207 217 through 231 247 through 255 in the other values the carry bit is 0 as verifed by leds. the pattern seems to be that the status bit will only show a carry when the lower byte of the user register being added to W is between 9 and 15, which coincides with a lower byte carry (STAUS bit 1 D being set). any thoughts? it is very perplexing. some of the code: Main call ad_portc goto Main ad_portc bsf ADCON0,GO ;Start A/D conversion Wait btfsc ADCON0,GO ; Wait for conversion to complete goto Wait movf ADRESH,W ;Write A/D result to PORTC movwf PORTC ;LEDs movwf Throttle movlw D'55' addwf Throttle,W btfss status, 0 FALSE goto false_10 TRUE bsf PORTB,0 GOTO continue_10 false_10 bcf PORTB,0 continue_10 return thanks, jeff -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.