Thanks for your replay Samo! 1. on your code below, why do you start with GET_TEMPERATURE instead of = FIRST CHANNEL? Here's what I'm trying to do: 1.Converting an analog voltage from 7-segments feeds into MUX1 (8:1) = then outputs to AN0 (PIC16C765) 2.another 7-segment feeds into MUX2 (8:1) then outputs AN1(PIC16C765) 3.B'00000011' For ADCON1. AN7-AN5 as digital. These three pin connected = to MUX1 & MUX2 select lines (A,B,C) 4.Need to do a continue LOOP count-up on the MUX1 & MUX2 first to select = IN0-IN6 from the MUX. to A/D --Rith -----Original Message----- From: Samo Benedicic [mailto:samo_benedicic@YAHOO.COM] Sent: Thursday, August 14, 2003 1:32 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: PIC:8-bit ADC 16C765 please help! Hi! You read the first, store result somewhere, than you read second channel. This is the code that reads four analog channels on PORTA. ADRESL is used, because 16f877 has 10 bit A/D. Hope it helps, Samo ... call GET_TEMPERATURE ... GET_TEMPERATURE btfsc ADCON0, GO ;conversion in progress? retlw 0 ;yes,return BANK1 movlw b'10000010' movwf ADCON1 ;RA0-RA4 are analog inputs, right justified movlw b'00001111' movwf TRISA ;RA0-RA3 are my channels, so RA4 is digital output in order BANK0 ;not to draw any current. SECOND_CHANNEL movlw b'01001001' ;8Tosc,A/D on,channel 1 movwf ADCON0 ; bcf PIR1,ADIF ;clear AD interrupt flag, since we'll be polling it movlw .8 movwf ACQ_CNT ACQ2_WAIT decfsz ACQ_CNT ;wait acquisition time goto ACQ2_WAIT bsf ADCON0, GO ;start conversation LOOP2 btfss PIR1,ADIF ;is conversion complete? goto LOOP2 ;no, wait BANK1 movf ADRESL,w ;move result somewhere BANK0 movwf SNS_SYSTEM THIRD_CHANNEL movlw b'01010001' ;8Tosc,A/D on,channel 2 movwf ADCON0 ; bcf PIR1,ADIF ;clear AD interrupt flag, since we'll be polling it movlw .8 movwf ACQ_CNT ACQ3_WAIT decfsz ACQ_CNT ;wait acquisition time goto ACQ3_WAIT bsf ADCON0, GO ;start conversation LOOP3 btfss PIR1,ADIF ;is conversion complete? goto LOOP3 ;no, wait BANK1 movf ADRESL,w ;move result somewhere BANK0 movwf SNS_OUT FOURTH_CHANNEL movlw b'01011001' ;8Tosc,A/D on,channel 3 movwf ADCON0 ; bcf PIR1,ADIF ;clear AD interrupt flag, since we'll be polling it movlw .8 movwf ACQ_CNT ACQ4_WAIT decfsz ACQ_CNT ;wait acquisition time goto ACQ4_WAIT bsf ADCON0, GO ;start conversation LOOP4 btfss PIR1,ADIF ;is conversion complete? goto LOOP4 ;no, wait BANK1 movf ADRESL,w ;move result somewhere BANK0 movwf SNS_KETTLE FIRST_CHANNEL movlw b'01000001' ;8Tosc,A/D on,channel 0 movwf ADCON0 ; bcf PIR1,ADIF ;clear AD interrupt flag, since we'll be polling it movlw .8 movwf ACQ_CNT ACQ1_WAIT decfsz ACQ_CNT ;wait acquisition time goto ACQ1_WAIT bsf ADCON0, GO ;start conversation LOOP1 btfss PIR1,ADIF ;is conversion complete? goto LOOP1 ;no, wait BANK1 movf ADRESL, w ;move result BANK0 movwf SNS_BOILER ;to OUT reg clrf ADCON0 ;turn off A/D module return --- Rith Nachampasak wrote: > Thanks Samo, > > Here what I had for setting A/D: > start bsf status,rp0 > ;switch to bank1 > movlw b'00000011' > ;input/output > movwf trisa > movlw b'00000000' > movwf trisb > ;output > movlw b'00000011' > ;config porta, bits 4,2,1,0 analog > > ;bits 7,6,5 digital I/O > Bit 4,2,1,0 was configured as analog input. That > mean if I wanna use two analog input, all I have to > do is connect two inputs to AN0 and AN1?? > How does it know which input to store on the ADRES? > > Again thanks for your help > > Rith __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu