|
文件: |
ADC应用实验.rar |
大小: |
18KB |
下载: |
下载 | |
ORG 0000H
AJMP MAIN
MAIN:MOV DPTR,#TBL
MOV 34H,#0H
MOV 35H,#5
MOV 38H,#20
MOV 7CH,#1
MOV 7DH,#2
MOV 7EH,#3
MOV 7FH,#4
MOV 79H,#7CH ;显示指针
MOV 78H,#0FEH ;显示位码
LOOP:NOP
LCALL XS4 ;动态显示
LCALL DEL
LCALL DEL
DJNZ 38H,LOOP
MOV 38H,#20
LCALL ADC3
LCALL NTOV
LCALL BCD
AJMP LOOP
;-------------
NTOV: MOV A,34H
MOV B,#50
MUL AB
MOV 34H,B
RET
;------------
BCD:MOV A,34H
MOV B,#10
DIV AB
MOV 7FH,B
MOV B,#10
DIV AB
MOV 7DH,A
MOV 7EH,B
;MOV 7CH,#10H
MOV A,7DH
JNZ BB
MOV 7DH,#10H
BB: RET
;------------------
ADC3:MOV P2,#7FH
MOV A,#0
MOVX @R0,A ;选择通道
NOP
NOP
AA: JB P3.3,AA
MOVX A,@R0 ;读取数据
MOV 34H,A
RET
;--动态显示每次1位------
XS4:
MOV A,#0H
MOV P2,#0FEH
MOVX @R0,A
MOV R0,79H
MOV A,@R0
MOVC A,@A+DPTR
CPL A
MOV P2,#0FEH
MOVX @R0,A
MOV P2,#0FDH
MOV A,78H
MOVX @R0,A
RL A
MOV 78H,A
INC 79H
CJNE R0,#7FH,XSE
MOV 79H,#7CH
MOV 78H,#0FEH
XSE: RET
;------------
DEL: DJNZ R7,DEL
RET
;---------------------
TBL: DB 0C0H,0F9H,0A4H,0B0H,99H ;01234
DB 92H,82H,0F8H,080H,090H ;56789
DB 88H,83H,0C6H,0A1H,86H,8EH ;ABCDEF
DB 0FFH,0BFH ; -
;-------------------------
注意:采用直接发控制时,写信号一定要参与译码!!!!!
阅读(223) | 评论(0) | 转发(0) |