;********************************************************************
;
; Author        : ADI - Apps            www.analog.com/MicroConverter
;
; Date          : October 2003
;
; File          : ADCldr.asm
;
; Hardware      : ADuC842/ADuC843
;
; Description   : Performs repeated single ADC conversions on ADC0
;                 Adjusts output of DAC0 to vary with LDR 
;		  
;********************************************************************

$MOD842                         ; Use 8052&ADuC842 predefined symbols

CHAN    EQU     3               ; convert this ADC input channel..
                                ; ..chan values can be 0 thru 8
;____________________________________________________________________
                                                  ; BEGINNING OF CODE
CSEG

ORG 0000h

        JMP     MAIN            ; jump to main program
;____________________________________________________________________
                                             ; INTERRUPT VECTOR SPACE
	

;====================================================================
                                                       ; MAIN PROGRAM
ORG 004Bh

MAIN:

; PRECONFIGURE...

        MOV     ADCCON1,#0ACh   ; power up ADC
        MOV     ADCCON2,#CHAN   ; select channel to convert
	MOV     DACCON,#03DH	; Dac 0  0-5V 12bits

; PERFORM REPEATED SINGLE CONVERSIONS...

AGAIN:  MOV     A,#01H		; Delay length
	SETB    SCONV           ; innitiate single ADC conversion
        		        ; ADC ISR is called upon completion
	JNB     ADCI,$
	CLR	ADCI
	MOV     DAC0H,ADCDATAH
	MOV     DAC0L,ADCDATAL
	
	JMP     AGAIN	
	
;____________________________________________________________________
END
