At 12:55 12/06/2002 +0300, Vasile Surducan wrote: >On Wed, 12 Jun 2002, Guillermo Rodriguez Garcia wrote: > > > > > I've searched the archive in www.piclist.com but all ADC code I > > can find always uses 8-bit results only, configuring the ADC to > > be left-justified and neglecting the ADRESL register. > >How ? this is a slighty adjusted copy from your code: > > bank0 > movf ADRESH, W ; get the 8 MSBs > movwf adc_high > bsf STATUS, RP0 ; Bank1 > movf ADRESL, W ; get the 2 MSBs > bcf STATUS, RP0 ; Bank0 -- here > movwf adc_low > ; bcf STATUS, RP0 ; Bank0 -- and not here ! Ouch. Of course you are right. Thanks to you and thanks to everyone else suggesting a solution as well... and sorry for the stupid question! >one Jal version: (didn't come across this one :) Thanks, G. >procedure ch_write is > delay_10uS ( 2 ) -- wait min aquisition time > adcon0_go = high -- start conversion > while adcon0_go loop end loop -- wait for ad completion > ch_hi = f877_adresh > bank_1 > asm movf f877_adresl,w > bank_0 > asm movwf ch_lo >end procedure > >Vasile > > > > > > > > > > > > > > Has anyone found this problem before? Any hints? > > > > Code follows: > > > > === Cut === > > > > Startup > > bsf STATUS, RP0 ; Bank1 > > movlw b'11111111' ; PORT A = all inputs > > movwf TRISA > > clrf TRISC ; PORT C = all outputs > > > > bcf STATUS, RP0 ; Bank0 > > movlw b'01000001' ; Fosc/8, A/D enabled > > movwf ADCON0 > > > > bsf STATUS, RP0 ; Bank1 > > movlw b'00001110' ; Left justify, 1 analog channel > > movwf ADCON1 ; VDD and VSS references > > > > movlw b'10000111' ; TMR0, 1:256 > > movwf OPTION_REG > > > > bcf STATUS, RP0 ; go back to Bank0 > > > > Main > > ; > > ; acquisition time before starting the AD conversion > > ; > > clrf TMR0 ; ensures that we start a complete T0 > > cycle here > > bcf INTCON,T0IF > > _T0Wait > > btfss INTCON,T0IF ; wait for Timer0 to timeout > > goto _T0Wait > > bcf INTCON,T0IF > > > > ; > > ; starts the AD conversion > > ; > > bsf ADCON0,GO ; start A/D conversion > > _waitAdc > > btfss PIR1, ADIF ; conversion complete? > > goto _waitAdc ; = NO (wait) > > > > bcf PIR1, ADIF ; clear conversion complete flag > > > > movf ADRESH, W ; get the 8 MSBs > > movwf adc_high > > bsf STATUS, RP0 ; Bank1 > > movf ADRESL, W ; get the 2 MSBs > > movwf adc_low > > bcf STATUS, RP0 ; Bank0 > > > > goto Main ; Loop forever > > === Cut === > > > > > > Thanks, > > G. > > > > -- > > http://www.piclist.com hint: The list server can filter out subtopics > > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > > > >-- >http://www.piclist.com hint: The list server can filter out subtopics >(like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics