Hi, Does anyone have tested and working code for ADC on theP16F877. What i = need is the code just to print the value of the ADC from some input, to = 10 LEDs. I've got 8 LED's working, but either I'm missing something, or = my PIC is bad, as i can't get the last two LSB's. They are permanently = on or off, don't change. The code I'm using is below, but if you have = any of your own code which does this, it'd be ver y much appreciated. Thanks -Peter Code--------------------------- ;Setup list P=3D16F877 include "c:\P16F877.inc" errorlevel -302 __CONFIG _CP_OFF & _HS_OSC & _WDT_OFF & _PWRTE_OFF & _BODEN_OFF & = _LVP_OFF ;Declarations CounterA equ 20h=20 org 0x000 goto Start org 0x004 Interrupt retfie Bank1 Macro ;bank switching macros bsf STATUS,RP0 bcf STATUS,RP1 bcf STATUS,IRP Endm Bank0 Macro bcf STATUS,RP0 bcf STATUS,RP1 bcf STATUS,IRP Endm =20 Init Bank1=20 movlw b'00000000' ;all of portb are output movwf TRISB movlw b'00000001' movwf TRISA movlw b'00000000' movwf TRISD movlw b'00001110' ;Right justified, channel RA0 is input to ADC movwf ADCON1 Bank0 ;bank 0 movlw b'00000000' ;all portb low movwf PORTB movlw b'00000000' movwf PORTD movlw b'10000001' ;RA0 Chn,ADC On,Fosc32 movwf ADCON0 return ADCStart call Delay bsf ADCON0,GO btfsc ADCON0,GO ;Wait for conversion to complete Goto$-1 movf ADRESH,w movwf PORTB movf ADRESL,w movwf PORTD =20 goto ADCStart return ;PIC Time Delay =3D 0.0000280 s with Osc =3D 20.000000 MHz Delay movlw D'45' movwf CounterA Loop decfsz CounterA,1 goto Loop return Start call Init Main call ADCStart goto Main End -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu