Joe ! it's too long :-))) function ch_write_1023 return byte is -- --------------------------------------------- ch_write bin2bcd3 ( msd, isd, lsd, ch_hi, ch_lo ) return isd return lsd end function smiling Vasile, On Wed, 12 Jun 2002, Jinx wrote: > This is a piece of trial ADC code from something I'm > working on at the moment. It shows 0000 to 1024 on > an LCD - the position of a 5k pot. I can't suggest a > reason for your adresl always containing 00. Unless > you've a typo that I've missed, the banking and code > looks very similar > > bank0 macro > bcf status,rp0 > bcf status,rp1 > bcf status,irp > endm > > bank1 macro > bsf status,rp0 > bcf status,rp1 > bcf status,irp > endm > > adch0 macro > bcf adcon0,chs0 > bcf adcon0,chs1 > bcf adcon0,chs2 > endm > > bank1 > movlw b'11111111' ;RA0 - RA7 analogue inputs > movwf trisa > clrf adcon0 > movlw b'00000000' ;set PortA I/O to all A2D > movwf adcon1 > > bank0 > call lcd_init ;initialise LCD screen > > clrf adcon0 > bsf adcon0,adcs1 ;select Fosc/32 @ 18.432MHz > bank1 > bsf adcon1,adfm ;right-justify result > bank0 > bsf adcon0,adon ;turn A/D on > > del256 ;short delay - temp > > adch0 ;select A/D channel 0 > > del256 ;short delay - temp > > bsf adcon0,go_done ;start conversion > nop > nop > btfsc adcon0,go_done ;test for end of sampling > goto $-1 > > movf adresh,w ;convert hi / lo to ASCII > movwf hi > bank1 > movf adresl,w > bank0 > movwf lo > call ascii16 > call line1 > call dig_out ;display > > -- > 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