程序设计内容
(1). 进行A/D转换时,采用查询EOC的标志信号来检测A/D转换是否完毕,若完毕则把数据通过P0端口读入,经过数据处理之后在数码管上显示。
(2). 进行A/D转换之前,要启动转换的方法:
ABC=110选择第三通道
ST=0,ST=1,ST=0产生启动转换的正脉冲信号 .
汇编源程序
CH EQU 30H
DPCNT EQU 31H
DPBUF EQU 33H
GDATA EQU 32H
ST BIT P3.0
OE BIT P3.1
EOC BIT P3.2
ORG 00H
LJMP START
ORG 0BH
LJMP T0X
ORG 30H
START: MOV CH,#0BCH
MOV DPCNT,#00H
MOV R1,#DPCNT
MOV R7,#5
MOV A,#10
MOV R0,#DPBUF
LOP: MOV @R0,A
INC R0
DJNZ R7,LOP
MOV @R0,#00H
INC R0
MOV @R0,#00H
INC R0
MOV @R0,#00H
MOV TMOD,#01H
MOV TH0,#(65536-4000)/256
MOV TL0,#(65536-4000) MOD 256
SETB TR0
SETB ET0
SETB EA
WT: CLR ST
SETB ST
CLR ST
WAIT: JNB EOC,WAIT
SETB OE
MOV GDATA,P0
CLR OE
MOV A,GDATA
MOV B,#100
DIV AB
MOV 33H,A
MOV A,B
MOV B,#10
DIV AB
MOV 34H,A
MOV 35H,B
SJMP WT
T0X: NOP
MOV TH0,#(65536-4000)/256
MOV TL0,#(65536-4000) MOD 256
MOV DPTR,#DPCD
MOV A,DPCNT
ADD A,#DPBUF
MOV R0,A
MOV A,@R0
MOVC A,@A+DPTR
MOV P1,A
MOV DPTR,#DPBT
MOV A,DPCNT
MOVC A,@A+DPTR
MOV P2,A
INC DPCNT
MOV A,DPCNT
CJNE A,#8,NEXT
MOV DPCNT,#00H
NEXT: RETI
DPCD: DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH,00H
DPBT: DB 0FEH,0FDH,0FBH,0F7H
DB 0EFH,0DFH,0BFH,07FH
END