I looked in the datasheet and here's what it said: 0000 A A A A A A A A VDD VSS 8 / 0 Which to me looks like all of PORTA as analog ins...what were you talking a= bout with RA4? Also, here is my ENTIRE code, with proper spacing: =09 LIST P=3D16F877A =09 INCLUDE "P16F877A.inc" __CONFIG _LVP_OFF & _LP_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF & _BODEN_OFF = & _DEBUG_OFF #DEFINE POT PORTA, 0 #DEFINE SPEAKER PORTA, 1 #DEFINE RELAY_0 PORTA, 2 #DEFINE RELAY_1 PORTA, 3 #DEFINE RELAY_2 PORTA, 4 #DEFINE RELAY_3 PORTA, 5 #DEFINE RS PORTB, 4 #DEFINE E PORTB, 5 #DEFINE TOGGLE PORTB, 6 #DEFINE POTSWITCH PORTB, 7 #DEFINE T1_ENABLE PORTC, 0 #DEFINE T2_ENABLE PORTD, 0 org 0 goto INIT ;------------------------------------------------------------; ; Initialization: configure the ports and peripherals ; ;------------------------------------------------------------; INIT: bsf STATUS, RP0 ; bcf STATUS, RP1 ; Bank 1 movlw b'00001110' ; Config all as digital except RA0 as analog movwf ADCON1 ;=20 movlw b'00000001' ; Potentiometer ; Piezzo Speaker ; Reed Relay Outputs movwf TRISA ; movlw b'11000000' ; LCD ; Drain & Clean Toggle ; Potentiometer Switch movwf TRISB ; movlw b'11111111' ; Data Read Enabled ; Tank 1 Int Val movwf TRISC ; movlw b'11111111' ; Data Read Enabled ; Tank 2 Int Val movwf TRISD ; bcf STATUS, RP0 ; Select Bank 0 clrf PORTA ; Initialize PORTA by clearing output data latches clrf PORTB ;=20 clrf PORTC ;=20 clrf PORTD ;=20 movlw b'01000001' ; Fosc/8 [7-6], A/D ch0 [5-3], a/d on [0] movwf ADCON0 ;-----------------------------------------------------------; ; Start: this is the main loop ; ;-----------------------------------------------------------; START: ;----------------------------------------- ;----- START OF POT POLLING ;----------------------------------------- =09 bsf ADCON0, GO ; Start A/D conversion AD_WAIT: btfsc ADCON0, GO ; Wait for conversion to complete goto AD_WAIT movf ADRESH, W movwf PORTB ; See if we get SOMETHING in ADRESH ; IF this works, we want to switch output ; of the 4 most sig digits to goto START ;----------------------------------------- ;----- END OF POT POLLING ;----------------------------------------- END --- Begin Orginal Message --- From: "Jan-Erik Soderholm XA (TN/PAC)" = To: PICLIST@MITVMA.MIT.EDU CC:=20 Date: 8/2/2003 12:16:15 PM rrc124+@PITT.EDU wrote: > Here is my source code... > Now the important part is where i set ADCON1... Probably not, since it looks OK... Is this a *complete* working example, btw ? > If i set it to all zeros (which in the datasheet says > all PORTA becomes ADC in)... No it doesn't, see port RA4. > Reed Relay Outputs There is no RA6 or RA7 ! > movf ADRESH, W > movwf PORTA PORTA is just 5 bits, and one of them is used as input. Perhaps better to use a full 8 bit port ? Now, not much help, maybe... Jan-Erik. PS. Besides, your code (and mail in a whole) is formatted in a way that made it hard to read the code and reply to. Make sure you keep your line lenghts below 70-75 chars, either by using some feature in your mail tool, or just simply by using your ENTER key at regular intervals... DS. -- 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.