PRD: RLC A
MOV P3.0,C
SETB P3.1
CPL P3.1
RET
;*****************************AD采样子程序******************************
ATOD:
HUMID: MOV DPTR,#0FB00H
CLR A
MOVX @DPTR,A
WAIT: JNB P3.4,READ ;转换结束信号
SJMP WAIT
READ: MOVX A,@DPTR
MOV B,#8
MUL AB
MOV 40H,A ;低位
MOV 41H,B ;高位
;MOV 40H,#0F8H
;MOV 41H,#07H
MOV 42H,#00H
;双字节二进制变BCD
;入口二进制42H,41H,40H高到低
;出口44H~43H,高到低
MUBTD: MOV R0,#NUMB2
MOV R7,#LENG2
CLR A
LOOP18: MOV @R0,A
INC R0
DJNZ R7,LOOP18
MOV R7,#LENG1
LOOP48: MOV R1,#NUMB1
MOV R6,#LENG3
CLR C
LOOP28: MOV A,@R1
RLC A
MOV @R1,A
INC R1
DJNZ R6,LOOP28
MOV R5,#LENG2
MOV R0,#NUMB2
LOOP38: MOV A,@R0
ADDC A,@R0
DA A
MOV @R0,A
INC R0
DJNZ R5,LOOP38
DJNZ R7,LOOP48
;拆字程序*************
MOV R0,#DISP4
MOV A,44H
ACALL SEPA1
MOV R0,#DISP6
MOV A,43H
ACALL SEPA1
RET
SEPA1: MOV 45H,A
ANL A,#0F0H
SWAP A
MOV @R0,A
INC R0
MOV A,45H
ANL A,#0FH
;SWAP A
MOV @R0,A
;RET
MOV DPTR,#0FB01H
CLR A
MOVX @DPTR,A
WAIT1: JNB P3.4,READ1 ;转换结束信号
SJMP WAIT1
READ1: MOVX A,@DPTR
CLR C
;MOV A,#68
CJNE A,#PPPP,LLI
LLI: JNC LL2 ;集电极电压大于5V则不报警
CLR P1.0 ;负载电压大于10V
RET
LL2: SETB P1.0
RET
;闭环*****************************
CLR C
MOV A,43H
SUBB A,3FH
MOV 46H,A ;低
MOV A,44H
SUBB A,3EH
MOV 47H,A ;高
;***********键盘显示中断程序*****************
;用定时中断0,显示扫描,30H~37H是段码存放地址,38H是位码地址
;8155 PB0~PB3段码输出,PB4~PB7位码输出
;用外部中断1键盘扫描,PA0~PA3列扫描输出,PC0~PC3;输入,P2.0接CS,P2.1接IO/M
;出口数值是0~15,存在3AH中,3BH用作放键暂存
;用寄存器第3组
;已用R0,R2,R3,R4,R5,R6,其中R0,R6为显示用,R1,R2,R3,R7为键盘用,R4,R5延时用
;*******************中断显示扫描子程序*****************
LED: PUSH PSW
PUSH ACC
PUSH B
PUSH DPH
PUSH DPL
SETB RS0
SETB RS1
MOV TH0,#0F8H ;2MS
MOV TL0,#30H
MOV A,@R0
ADD A,WEI
MOV DPTR,#PORTB
MOVX @DPTR,A
MOV A,WEI
ADD A,#10H
MOV WEI,A
INC R0
;ACALL DELAY
DJNZ R6,LED1
MOV WEI,#00H
MOV R0,#DISP0
MOV R6,#8
LED1: POP DPL
POP DPH
POP B
POP ACC
POP PSW
RETI
;**************中断键盘扫描子程序************
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页