If you have used more than 1 AD input ( the multiplexing mode ) than is almost sure you haven't used the right delayed between various channels ( 20uS ). I'm not sure if you don't have also some noise or bad ground design. regards, Vasile http://www.geocities.com/vsurducan On Tue, 14 Jan 2003, Jai Dhar wrote: > Hello, > > Have a question about the A/D on the 16f877. I gave my first shot on coding a > simple converter that uses a divider from a pot as an input to one of the > pins. Now I'm pretty sure I have my code set right, because when I read the > results (I did about 5 test cases), they all seem pretty accurate, except with > a few problems. > > Some of the pins had constantly a constantly changing voltage that was > registering on my DMM. Most of the pins would be stable, either ~0 or 5.2V, > but some of them, each on different tests, would be fluctuating, sometimes > from 2.5-2.9V, and sometimes other values. Is this normal? Does the fact that > my program keeps going in a loop affect this (even though I'm reading the Go/! > Done flag to check when it's done)? And it seems to be different pins each > time, so there doesn't appear to be a definite pattern. On some readings, all > the pins are perfect. Any ideas? > > Thank you, > > Jai > > PS: Just in case, I have my Code below. > > clrf TRISB ;Set all of Port B and D to outputs > clrf TRISD > > movlw 0xff > movwf TRISA > > movlw 0x0E ;Set Justification and set RA0 as the only analog input > movwf ADCON1 > > > bcf STATUS, RP0 ;Switch back to Bank 0 > > movlw 0xC1 ;Select A/D on, Channel 0 and RC Clock > movwf ADCON0 > > movlw 0x00 > movwf PORTB ;initialize the ports to a blank value. > movwf PORTD > > Start1 > > > bsf ADCON0, GO ;Start the A/D. > Loop1 > btfsc ADCON0, GO > goto Loop1 > > ;Finished The A/D conversion > > movf ADRESL, 0 ;Move the low byte into Port B (B<7>:B<6>) > movwf PORTB > > movf ADRESH, 0 ;Move the high byte into Port D (D<7>:D<0>) > movwf PORTD > > > goto Start1 ;Start it all over again. > > > > > > ---------------------------------------- > This mail sent through www.mywaterloo.ca > > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body