	TITLE	ADC ROUTINES
			

        CODE
* ADC initialization routine
IADC    BSET	OPTION,$80	;power up ADC (ADPU=1)
	BCLR	OPTION,$40	;select clock E (CSEL=0)
        LDAA    #$00            ;MULT=0, SCAN=0, channel 0
	RTS		

* START CONVERSIONS AND READ ADC
READ_ADC JSR    RAD0
         RTS
***********************************************************
* RAD0 - read ADC channel 0
***********************************************************


RAD0    LDAA	#$00	        ;MULT=0 - select channel 0
	STAA	ADCTL	        ;start conversion 
RAD05   LDAA	ADCTL	
	ANDA	#$80	        ;poll CCF until true
	BEQ	RAD05
	LDAA	ADR1	        ;get result in A for AN0
	STAA	AN0	        ;update variables
	RTS		


	END		
