
#include "aduc841.h"
			org		0000h
			sjmp	ayar
			org		000bh
			sjmp	T0_kesme_fonk
ayar:		// cevap 7_2

			
			mov		ADCCON1,#10111100b; dahili ref, ck1_ck0=11, aq1_aq0=11
			mov		ADCCON2,#00000000B; kanal 0
			
			mov		tmod,#00000001b; mod 1 16 bit
			// 2ms için 11059200*(2/1000)= kare dalga gerekir.
			//= 22118d
			// 65535-22118=43417D
			mov		dptr,#43517d
			mov		tl0,dpl
			mov		th0,dph
			setb	et0   ; timer kesmesi
			setb	ea
			setb	tr0
			
basla:		
			nop
			nop
			sjmp 	basla	

T0_kesme_fonk:
			mov		tl0,#dpl
			mov		th0,dph  ; sayici orj degerleri yukleniyor
			
			setb	sconv	; çevrim basla
			jnb		adci,$	; adc çevrim bitti mi  testi
			clr		adci
			
			mov		r0,adcdatah
			mov		r1,adcdatal
			
			reti
			
			
			
			END