	include <p18f4520.inc>

	ORG	0x00
	goto	init

	ORG	0x08		;interrupt vector


init
	movlw	B'00000000'
	movwf	TRISC		;portc as output
	movlw	B'00000001'	
	movwf	TRISA		;porta, 0 as input

	movlw	B'00001110'	;use Vss and Vdd as references, only use AN0
	movwf	ADCON1		;
    movlw   B'00000001' ;AN0, A/D on           
    movwf   ADCON0		;
	movlw	B'00000010'	;Left Justified 0Tad  Fosc/32
	movwf	ADCON2		;

	goto	main

main
    bsf     ADCON0,GO       ;Start A/D conversion
Wait
    btfsc   ADCON0,GO       ;Wait for conversion to complete
    goto    Wait

    movf    ADRESH,W        ;Write A/D result to PORTC
    movwf   PORTC

	goto	main

	END