> ;------------------------- READ IN ANALOGUE SIGNALS ROUTINE > ------------------- > ; THIS ROUTINE READS IN THE ANALOGUE VOLTAGES, > > Read_analouge ; ENTER WITH CHANNEL NUMBBER 0-4 IN W > CLRC ; CLEAR CARRY BEFORE COMMENCING > ANDLW B'00000111' ; ENSURE NO ERRORS > MOVWF GP1 ; TEMP STORE > RLF GP1,F > RLF GP1,F > RLF GP1,W ; SPIN TO PUT THE CHANELS IN THE RIGHT > PLACE > ADDLW B'11000001' ; SET ADCON0 TO CONVERSION TIME 0F RC > 2-6us > Gie_off ; disable int's > MOVWF ADCON0 ; DO IT > BCF PIR1,ADIF ; clear intrupt flag > MOVLW .23 ; 69 us wait for channel sel to register > CALL SHORT ; SETTLING DELAY FOR A/D > BSF ADCON0,2 ; START THE CONVERSION > btfsc ADCON0,2 ; test for finished > goto $-1 ; no then retest > Gie_on ; enable int's > RETLW 0 ; EXIT > > > > Try this it works enter with rreqd channel in w exit with result in > adres h,l Why do you need to disable interrupts around the acquisition and conversion? A longer acquisition time does no harm, and the converted value stays around after a conversion until you start another one. Generally I don't like doing "long" things with interrupts disabled. This routine requires the direct register bank to be set to 0, although there is no mention of that requirement. A better strategy is probably to allow any bank on entry and set it as required. As an aside, I've found it useful to read the A/D often based on an interrupt. There can be a separate interrupt for starting a conversion and getting the result. I usually switch to the next channel as soon as the conversion for the previous channel is complete. This background A/D reading code can perform a little optional filtering on the values, then update a software value that is always kept live. When the foreground code needs the current A/D value, it just reads it immediately from the live software value. Note that interrupts must be disabled around this read if it is more than one byte in size. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu