51单片机STC89C52 AD模数转换
2018-06-22 来源:eefocus
CSDA BIT P3.2
WRR BIT P3.6
RDD BIT P3.7
WELA BIT P2.7
DULA BIT P2.6
CSAD BIT P0.7
DIOLA BIT P2.5
ORG 0000H
LOOP0:
MOV P0,#0FFH ;关数码管显示
SETB WELA
SETB RDD
SETB WRR
STARTAD: ;开始转换
CLR CSAD
//NOP
CLR WRR
//NOP
SETB WRR
//NOP
SETB CSAD
LCALL DELAY ;延时,等待转换完成
READAD: ;读取转换结果
CLR CSAD
//NOP
CLR RDD
//NOP
MOV P1,#0FFH
MOV A,P1
SETB RDD
SETB CSAD
MOV P1,A ;送LED显示,锁存
SETB DIOLA
CLR DIOLA
LCALL DELAY4S
SJMP STARTAD
DELAY: ;延时
SETB RS1
MOV R2,#04H
DELAY2:
MOV R1,#1
DELAY1:
MOV R0,#250
DELAY0:
NOP
NOP
DJNZ R0,DELAY0
DJNZ R1,DELAY1
//DJNZ R2,DELAY2
CLR RS1
RET
DELAY4S: ;延时
SETB RS1
MOV R3,#02H
DELAY30:
MOV R2,#04H
DELAY20:
MOV R1,#250
DELAY10:
MOV R0,#250
DELAY00:
NOP
NOP
DJNZ R0,DELAY00
DJNZ R1,DELAY10
DJNZ R2,DELAY20
DJNZ R3,DELAY30
CLR RS1
RET
END