第4节 实验测试
4.1循环显示“HELLO888”
编一小程序,实现数码管八跑马——循环显示“HELLO888”。源程序如下:
RG 0000H
HL:MOV P1,#89H
MOV P3,#00H
ACALL DELAY
MOV P1,#86H
MOV P3,#08H
ACALL DELAY
MOV P1,#0C7H
MOV P3,#10H
ACALL DELAY
MOV P1,#0C7H
MOV P3,#18H
ACALL DELAY
MOV P1,#0C0H
MOV P3,#20H
ACALL DELAY
MOV P1,#80H
MOV P3,#28H
ACALL DELAY
MOV P1,#80H
MOV P3,#30H
ACALL DELAY
MOV P1,#80H
MOV P3,#38H
ACALL DELAY
LJMP HL
DELAY: MOV R0,#0DFH
D1: MOV R1,#0FFH
DJNZ R1,$
DJNZ R0,D1
RET
4.2、键盘及数字显示结合
编一小程序,实现键盘及数字显示结合——按键盘1数码管显示1,按键盘2数码管显示3,按键盘3数码管显示3,按键盘4数码管显示4,按键盘5数码管显示5,按键盘6数码管显示6,按键盘7数码管显示7,按键盘8数码管显示8,按键盘9数码管显示9,按键盘10数码管显示A,按键盘11数码管显示b,按键盘12数码管显示C,按键盘13数码管显示d,按键盘14数码管显示E,按键盘15数码管显示F。源程序如下所示:
ORG 0000H
LL:ACALL HH
ACALL L0
ACALL L2
ACALL L3
ACALL L4
ACALL L5
ACALL L7
SJMP LL
CLR P3.4
CLR P3.3
H0:JB P3.2,Y0
SJMP H0
Y0:MOV P1,#88H
ACALL HH
SJMP LL
E0:JB P3.7,F0
SJMP E0
ACALL HH
SJMP LL
L1:CLR P3.5
CLR P3.4
SETB P3.3
JNB P3.7,E1
RET
H1:JB P3.2,Y1
SJMP H1
Y1:MOV P1,#83H
ACALL HH
LJMP LL
E1:JB P3.7,F1
SJMP E1
ACALL HH
SJMP LL
L2:CLR P3.5
SETB P3.4
CLR P3.3
JNB P3.2,H2
JNB P3.7,E2
RET
H2:JB P3.2,Y2
SJMP H2
Y2:MOV P1,#0C6H
ACALL HH
LJMP LL
E2:JB P3.7,F2
SJMP E2
F2:MOV P1,#0B0H
ACALL HH
LJMP LL
L3:CLR P3.5
SETB P3.4
SETB P3.3
JNB P3.2,H3
JNB P3.7,E3
RET
H3:JB P3.2,Y3
SJMP H3
ACALL HH
LJMP LL
E3:JB P3.7,F3
SJMP E3
F3:MOV P1,#99H
ACALL HH
LJMP LL
L4:SETB P3.5
CLR P3.4
CLR P3.3
JNB P3.7,E4
RET
H4:JB P3.2,Y4
SJMP H4
Y4:MOV P1,#86H
ACALL HH
LJMP LL
E4:JB P3.7,F4
SJMP E4
F4:MOV P1,#92H
ACALL HH
LJMP LL
L5:SETB P3.5
CLR P3.4
SETB P3.3
JNB P3.2,H5
JNB P3.7,E5
RET
H5:JB P3.2,Y5
SJMP H5
ACALL HH
LJMP LL
E5:JB P3.7,F5
SJMP E5
ACALL HH
LJMP LL
L6:SETB P3.5
SETB P3.4
CLR P3.3
JNB P3.2,H6
JNB P3.7,E6
RET
H6:JB P3.2,Y6
SJMP H6
Y6:MOV P1,#89H
ACALL HH
LJMP LL
SJMP E6
F6:MOV P1,#0F8H
ACALL HH
LJMP LL
L7:SETB P3.5
SETB P3.4
SETB P3.3
JNB P3.2,H7
JNB P3.7,E7
RET
H7:JB P3.2,Y7
SJMP H7
Y7:MOV P1,#0C7H
ACALL HH
LJMP LL
E7:JB P3.7,F7
SJMP E7
F7:MOV P1,#80H
ACALL HH
LJMP LL
HH:MOV P3,#0FFH
ACALL DELAY
MOV P3,#0F7H
ACALL DELAY
MOV P3,#0EFH
ACALL DELAY
MOV P3,#0E7H
ACALL DELAY
MOV P3,#0DFH
ACALL DELAY
MOV P3,#0D7H
ACALL DELAY
MOV P3,#0CFH
ACALL DELAY
MOV P3,#0C7H
ACALL DELAY
RET
DELAY:MOV R0,#01H
DAl: MOV R1,#9FH
DA2: NOP
NOP
NOP
NOP
DJNZ R1,DA1
DJNZ R0,DA2
RET
END
4.3、温度设定和传送电路
编一小程序,实现温度设定和传送电路——以下是双机串口通讯主程序流程图:
图4-1 双机串口通讯流程图
;程序1------方式2两位设定就不可的
FLAGA BIT 2AH.0
FLAGB BIT 2AH.1
FLAG1 BIT P3.4
FLAG2 BIT P3.5
GUAN1 EQU 30H
GUAN2 EQU 31H
GUAN3 EQU 32H
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页