Network Engg

Sunday, August 18, 2013

adc and dac for keil compiler

ADC:


ORG 0000H
READ BIT P2.0
WRITE BIT P2.1
INTR BIT P2.2
ACALL INIT
MOV P3,#0FFH
SETB INTR
START:
CLR WRITE
SETB READ
CALL DELAY
SETB WRITE
CALL DELAY
JB INTR,$
CLR READ
CALL CONV
CALL DISPLAY
ACALL DELAY1
SJMP START
INIT:
MOV A,#38H
ACALL COM
MOV A,#0EH
ACALL COM
MOV A,#01H
ACALL COM
RET
CONV:
MOV A,P3
MOV B,#10
DIV AB
MOV R7,B
MOV B,#10
DIV AB
MOV R6,B
MOV R5,A
RET
DISPLAY:
MOV A,#01H
ACALL COM
MOV A,#80H
ACALL COM
MOV R4,#08D
MOV A,#00H
MOV DPTR,#MYDATA
 NEXT: CLR A
  MOVC A,@A+DPTR
ACALL DATA1
INC DPTR
CLR A
DJNZ R4,NEXT
MOV A,R5
ADD A,#30H
ACALL DATA1
MOV A,R6
ADD A,#30H
ACALL DATA1
MOV A,R7
ADD A,#30H
ACALL DATA1
RET
COM:
ACALL CHKDB7
        CLR P2.5
CLR P2.6
SETB P2.7
MOV P1,A
CLR P2.7
RET
DATA1:
ACALL CHKDB7
SETB P2.5
CLR P2.6
SETB P2.7
MOV P1,A
CLR P2.7
RET
CHKDB7:
SETB P1.7
CLR P2.5
SETB P2.6
BAC: CLR P2.7
SETB P2.7
JB P1.7, BAC
RET
DELAY:
MOV R2,#0AAH
DJNZ R2,$
RET
DELAY1:
MOV R0,#08h
 OUT3: MOV R1,#0FFh
 OUT2:  MOV R2,#0FFh
  DJNZ R2,$
DJNZ R1,OUT2
DJNZ R0,OUT3
RET
MYDATA:DB "DATA IS:"
END  

DAC:



org 000h
mov a,#00h
LABEL:mov p2,a
/*acall delay*/
inc a
cjne a,#0ffh,LABEL
LABEL1:mov p2,a
/*acall delay*/
dec a
cjne a,#00h,LABEL1
sjmp LABEL
delay:
mov r2,#02fh
LABEL2:mov r1,#0ffh
LABEL3:mov r0,#0ffh
djnz r0,$
djnz r1,LABEL3
djnz r2,LABEL2
ret
end

No comments:

Post a Comment