ORG 0000H
LJMP MAIN
ORG000BH
LJMP T00
//ORG001BH
//LJMP T11
ORG 0030H
//=======程序初始化=============================
MAIN:
MOV TMOD,#11H
MOV TH0,#3CH
MOV TL0,#0B0H
MOV TH1,#0F0H
MOV TL1,#0B0H
SETB EA
SETB ET0
// SETB ET1
SETB TR0
//橘段配 SETB TR1
CLR P3.4
MOV R7,#00H 秒值
MOV 30H,#00H 秒个位值
MOV 31H,#00H 秒十位值
MOV 32H,#00H 分个位
MOV 33H,#00H 分十位
MOV 34H,#00H 时个位
MOV 35H,#00H 时十位
MOV 44H,#00H 秒表毫秒十燃纳位
MOV 45H,#00H 秒表秒毫秒百位
MOV 46H,#00H 秒表秒个位
MOV 47H,#00H 秒表秒十位
MOV 48H,#00H 秒表分个位
MOV 49H,#00H 秒表分十位
MOV P2,#0F0H P2口按键初始化
MOV 40H,#01H 数码管休眠值 /流水灯/秒表开关数
MOV 41H,#08H 流水灯循环值
MOV 42H,#00H 秒表暂停
// ACALL T11
//-----------------------------------------------
MAIN1:
MOV P0,#0FFH
MOV P1,#0FFH
MOV R0,40H
CJNE R0,#01H,ACL1
ACALL MAIN2时钟显示
ACL1:CJNE R0,#02H,ACL2
ACALL MAIN3秒表
ACL2:CJNE R0,#03H,ACL3
ACALL LED流水灯
ACL3:ACALL KEY 按键扫描
/圆指/ ACALL BAO定时报警
LJMP MAIN1
//=======报警子程序============================
BAO:MOV R4,33H
CJNE R4,#03H,YY1
CLR P3.2
ACALL KEY
LJMP YY2
YY1:CJNE R4,#05H,YY2
SETB P3.2
ACALL KEY
YY2:RET
//======时钟扫描子程序=======================
MAIN2:
MOV A,30H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.0
ACALL DELAY
MOV A,31H
MOV DPTR,#TAB
MOVC A,@A+ DPTR
MOV P0,A
CLR P1.1
SETB P1.0
ACALL DELAY
MOV A,32H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.2
SETB P1.1
ACALL DELAY
MOV A,33H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.3
SETB P1.2
ACALL DELAY
MOV A,34H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.4
SETB P1.3
ACALL DELAY
MOV A,35H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.5
SETB P1.4
ACALL DELAY
MOV P0,#7FH
MOV P1,#0EBH
ACALL DELAY
MOV P1,#0FFH
RET
//========秒表扫描子程序=========================
MAIN3:
MOV A,44H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.0
ACALL DELAY
MOV A,45H
MOV DPTR,#TAB
MOVC A,@A+ DPTR
MOV P0,A
CLR P1.1
SETB P1.0
ACALL DELAY
MOV A,46H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.2
SETB P1.1
ACALL DELAY
MOV A,47H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.3
SETB P1.2
ACALL DELAY
MOV A,48H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.4
SETB P1.3
ACALL DELAY
MOV A,49H
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
CLR P1.5
SETB P1.4
ACALL DELAY
MOV P0,#7FH
MOV P1,#0EBH
ACALL DELAY
MOV P1,#0FFH
RET
//=======定时器T0中断服务========================
T00:MOV TH0,#0D8H
MOV TL0,#0F0H
INC R7
CJNE R7,#64H,AA
MOV R7,#00H
//-------时钟跑值--------------------------------
TK1:INC 30H 每秒钟秒个位增一
MOV R6,30H
CJNE R6,#0AH,AA
MOV 30H,#00H
TK2:INC 31H
MOV R6,31H
CJNE R6,#06H,AA
MOV 31H,#00H
TK3:INC 32H
MOVR6,32H
CJNE R6,#0AH,AA
MOV32H,#00H
TK4:INC33H
MOVR6,33H
CJNE R6,#06H,AA
MOV33H,#00H
TK5:INC34H
MOVR5,34H
MOVR6,35H
CJNE R5,#04H,TK6
CJNE R6,#02H,TK6
MOV34H,#00H
MOV35H,#00H
TK6:CJNE R5,#0AH,AA
MOV34H,#00H
INC35H
//-------秒表跑值----------------------
AA:
MOV R5,42H
CJNE R5,#01H,TK7
INC 44H
TK7:MOV R5,44H
CJNE R5,#0AH,AA1
MOV 44H,#00H
INC 45H
MOV R5,45H
CJNE R5,#0AH,AA1
MOV 45H,#00H
INC 46H
MOV R5,46H
CJNE R5,#0AH,AA1
MOV 46H,#00H
INC 47H
MOV R5,47H
CJNE R5,#06H,AA1
MOV 47H,#00H
INC 48H
MOV R5,48H
CJNE R5,#0AH,AA1
MOV 48H,#00H
INC 49H
MOV R5,49H
CJNE R5,#06H,AA1
MOV 49H,#00H
AA1:RETI
//====定时器T1中断服务子程序====================
//T11:MOV TH1,#0F0H
// MOV TL1,#0B0H
// RETI
//******定时时间调整子程序*************************//
TBAO:
MOV 50H,#00H
MOV 51H,#00H
MOV 52H,#00H
MOV 53H,#00H
MOV 54H,#00H
MOV 55H,#00H
MOV R3,50H
DJNZ 30H,RET1
RET1: RET
//======键盘扫描子程序==========================
KEY:MOV P2,#0F0H
MOV R3,P2
CJNE R3,#0F0H,KE0
LJMP KK13
KE0:CJNE R3,#0E0H,KE1 P2.4行
MOV P2,#0EFH
JB P2.3,KK1 //用作调定时时间 K13 秒个位增一
ACALL DELAY1
ACALL TK1
KK1:JB P2.2,KK2 K14 秒十增一
ACALL DELAY1
ACALL TK2
KK2:JB P2.1,KK3 K15 分个位增一
ACALL DELAY1
ACALL TK3
KK3:JB P2.0,KE1 K16 分十位增一
ACALL DELAY1
ACALL TK4
KE1:MOV P2,#0DFH P2.5行
JB P2.3,KK4 K9 时个位增一
ACALL DELAY1
ACALL TK5
KK4:JB P2.2,KK5 K10 时十位增一
ACALL DELAY1
INC 35H
MOV R3,35H
CJNE R3,#03H,HH0
MOV 35H,#00H
LJMP KK5
HH0:CJNE R3,#02H,HH1
LJMP KK5
HH1:CJNE R3,#01H,HH2
LJMP KK5
HH2:MOV 35H,#00H
KK5:JB P2.1,KK6
ACALL DELAY1 K11开/关蜂鸣器
CPL P3.2
KK6:JB P2.0,KE2 K12 秒表暂停
MOV 42H,#00H
KE2:MOV P2,#0BFH P.6行
JB P2.3,KK7K5 时钟暂停/取消暂停
ACALL DELAY1
CPL ET0
KK7:JB P2.2,KK8 K6 显示/休眠/流水灯
ACALL DELAY2
INC 40H
MOV R3,40H
CJNE R3,#04H,KK8
MOV 40H,#01H
KK8:JB P2.1,KK9
// ACALL DELAY3 K7 秒表清0
MOV 44H,#00H
MOV 45H,#00H
MOV 46H,#00H
MOV 47H,#00H
MOV 48H,#00H
MOV 49H,#00H
KK9:JB P2.0,KE3 K8 秒表开始跑
MOV 42H,#01H
KE3:MOV P2,#7FH P2.7行
JB P2.3,KK10 K1 秒十位减一
ACALL DELAY1
MOV R3,31H
CJNE R3,#00H,JA1
LJMP KK10
JA1:DEC 31H
KK10:JB P2.2,KK11K2分个位减一
ACALL DELAY1
MOV R3,32H
CJNE R3,#00H,JA2
LJMP KK11
JA2: DEC 32H
KK11:JB P2.1,KK12 K3 分十位减一
ACALL DELAY1
MOV R3,33H
CJNE R3,#00H,JA3
LJMP KK12
JA3:DEC 33H
KK12:JB P2.0,KK13 K4 时个位减一
ACALL DELAY1
MOV R3,34H
CJNE R3,#00H,JA4
LJMP KK13
JA4:DEC 34H
KK13:RET
//=====流水灯子程序===========================
LED: MOV A,#0feH
MOV 41H,#08H
MOV P0,#0FFH
LED1:
MOV P1,A
MOV R3,#100
D0: ACALL DELAY
DJNZ R3,D0
MOV R3,41H
DJNZ R3,AAA
LJMP BB
AAA:RL A
MOV 41H,R3
ACALL KEY
LJMP LED1
BB:
MOV 41H,#07H
CC: MOV P1,A
MOV R3,#30
D1: ACALL DELAY
DJNZ R3,D1
MOV R3,41H
DJNZ R3,DD
LJMP LED0
DD:RR A
MOV 41H,R3
ACALL KEY
LJMP CC
LED0:RET
//=====延时子程序==============================
DELAY:MOV R1,#250
DEL1:NOP
NOP
NOP
NOP
DJNZ R1,DEL1
RET
//====调用时钟显示作延时========================
DELAY1:MOV R2,#20
DELA3: ACALL MAIN2
DJNZ R2,DELA3
RET
//====调用秒表显示作延时========================
DELAY3:MOV R2,#20
DELA5:ACALL MAIN3
DJNZ R2,DELA5
RET
//====调用延时子程序作延时======================
DELAY2:MOV R2,#100
DELA4:ACALL DELAY
DJNZ R2,DELA4
RET
//======共阳数码管段码表=================================
TAB:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,87H
END
ms50 DATA 31H50ms计数内存地址sec DATA 32H秒计数内存地址min DATA 33H 分计数内存地址hour DATA 34H 时计数内存地址buffer DATA 35H 显示十进制内存起始地址EXTRN CODE(Display8)外部显示子程序(跟硬件设计有关,原文未列出) ORG 0000H LJMP STAR转主程序 ORG 000BH LJMP INT_Timer0转50ms定时器中断处理程序ORG 0100HSTAR: MOV SP,#60H 主程序 MOV ms50,A50ms计数器初始化到0 MOV hour,#12小时初始化为12 MOV min,#59分钟初始化为59 MOV sec,#50秒初始化为50 MOV TH0,#60初始化定时器T0为50ms的数据(跟时钟频率和定时器模式有关) MOV TL0,#176 MOV TMOD,#1初始化定时器模式 MOV IE,#82H设定中断 SETB TR0 开定时器0STAR1: LCALL Display 调用显示转换程序(先将16进制转为BCD码再显示) JNB F0,$等待中断处理握兆完成标弯逗志 CLR F0复位中断处理完成标志SJMP STAR1循环显示中断服务程序INT_Timer0:
MOV TL0,#176-550ms定时器计数器初始值再装入(埋皮卖-5为微调,含响应中断用时) MOV TH0,#60 PUSH 01H压入堆栈 MOV R1,#ms50装入50ms计数内存地址数31H INC @R150ms计数内存加1
CJNE @R1,#20,ExitInt不够1秒,退出 MOV @R1,#050ms计数内存复位为0(31H)
INC R1转为秒内存地址(32H)
INC @R1秒计数内存加1 CJNE @R1,#60,ExitInt1不够60秒,退出 MOV @R1,#0够60秒,秒计数复位为0 INC R1转为分计数内存地址(33H)
INC @R1 分计数内存加1 CJNE @R1,#60,ExitInt1不够60分,退出 MOV @R1,#0够60分,分复位为0 INC R1转为时内存地址(34H) INC @R1 时计数内存加1 CJNE @R1,#24,ExitInt1不够24时,退出 MOV @R1,#0时计数内存复位为0ExitInt1:
SETB F0置位中断处理完成标志ExitInt:
POP 01H恢复现场 RETI 退出中断
HexToBCD:16进制转BCD码
MOV B,#10 DIV AB MOV @R0,B存余数(10进制个位) INC R0转伤地址 MOV @R0,A存伤(10进制十位) INC R0转下一次余数地址 RET
Display:显示转换与调用显示程序
MOV R0,#buffer10进制BCD秒显示缓存地址(35H) MOV A,sec ACALL HexToBCD十进制秒转换后存在(35H)、(36H) MOV @R0,#10H(37H)=#10H,秒与分之间的间隔,无实际意义,或与dispaly8有关
INC R010进制BCD分显示缓存地址(38H)
MOV A,min ACALL HexToBCD十进制分转换后存在(38H)、(39H)
MOV @R0,#10H(3AH)=#10H,分与时之间的间隔,无实际意义,或与dispaly8有关
INC R010进制BCD时显示缓存地址(3BH)
MOV A,hour ACALL HexToBCD十进制时转换后存在(3CH)、(3DH)
MOV R0,#buffer恢复显示缓存地址(35H),为dispaly8置初始显示地址 LCALL Display8调用实际显示程序 RET END
20h.1半点标示位
20H.2闹钟设置中........标示,为了显示区别用
20H.3闹钟设置时间CHECK到,使能标志位
20H.5开/关闹钟设置中........标示谨培
20H.6闹钟1开关标志位
20H.7闹钟2开关标志位
psw.5用来做显示开关标志位
21,22,23,24这里设置第一个闹钟的时间
25,26,27,28这里设置第二个闹钟的时间
29H
P0口输出数码管段码,
P2口 输出位选信号
70H存放P1.0--3按钮值,
71H--78H存放当前系统定时时间
78H 77H 76H 75H 74H 73H 72H 71H
星期* 小时 分钟 秒钟
ts equ 24h 这里设置`24小时周期制
trrequ #0bbh 这个是温度,晶振等的时间补偿值,
org 0000h 定时太慢此值调大,定时太快调小
jmp main
org 0bh 定时器0中断入口矢量
jmp bz
org 1bh 定时器1中断入口矢量
jmp t1int
org 0100h 主程序
主程序
main:clr p3.0 关继电器
mov sp,#30h
mov r3,#20
mov tmod,#10h
mov tl0,#06h 定时器1,方式1,定时 50 MS
mov th0,#06h
mov tl1,#0b0h
mov th1,#3ch
mov ie,#88h 开定时器1中断
mov 65h,#5
mov 66h,#100
mov 64h,#4
clr psw.5
clr p3.0
setb pt1 设置T1为高优先级中断
setb tr1
clr tr1开启T1中断
acall send 71h--78h 清零
acall send1 20h--29h 清零
dd: acall daa进行十进制调整71H-79H
acall compare第一闹钟
acall compare1 第二闹钟 设置值
acall sound
acall disp 数码管显示,78H--71H分别对应着8个数码管镇型显示
acall key_scanf 按钮控制
acall time_adj 时间调整
acall lasttime 调用上一次的设置值为当前定时值
acall alarm1_set 设置定时开/关闹钟
ajmp dd
调用上次祥旅唯值为设置时间
lasttime:push acc
mov a,70h
jnb acc.2,return1
clr p3.0 紧急暂停按钮,按下后暂停,并把上次设定值恢复.
clr tr1
mov 73h,21h
mov 74h,22h
wait7:acall disp
acall key_scanf
mov a,70h
jnb acc.0,wait7
mov 71h,#0
mov 72h,#0
mov 79h,#0
mov tl1,trr
mov th1,#3ch
mov r3,#20
setb tr1
setb p3.0
return1:pop acc
ret
daa: push acc 对当前系统时间进行十进制调整
mov 71h,79h
mov r1,#71h
cjne @r1,#10,s2
mov 71h,#0h
mov 79h,#0
inc 72h
mov r1,#72h
cjne @r1,#6,s2
mov 72h,#0h
dec 73h
mov r1,#73h
cjne @r1,#255,s2
dec 74h
mov 73h,#9
s1: pop acc
ret
s2: mov r1,#73h
cjne @r1,#0,s1
mov r1,#74h
cjne @r1,#0,s1
clr p3.0
clr tr1
sjmp s1
h_half: 半点CHECK
mov r1,#73h
mov a,74h
swap a
xchd a,@r1
cjne a,#29h,o25 CHECK 当前时间是否为29分钟
xchd a,@r1
mov r1,#71h
mov a,72h
swap a
xchd a,@r1
cjne a,#59h,o25 CHECK 当前时间为59秒?
setb tr0启动T0
setb 20h.1 enable 半点flag bit
o25: xchd a,@r1
ret
compare: 闹钟1设置时间与当前时间比较
push acc
jnb 20h.6,nequ 闹钟1开/关标志位
mov a,73h
cjne a,21h,nequ 分低位
mov a,74h
cjne a,22h,nequ 分高位
mov a,75h
cjne a,23h,nequ 小时低位
mov a,76h
cjne a,24h,nequ 小时高位
setb 20h.3 到闹钟设置时间,使能闹钟报警标志位
nequ:pop acc
ret
compare1: 闹钟2设置时间与当前时间比较
push acc
jnb 20h.7,nequ33 闹钟2开/关标志位
mov a,73h
cjne a,25h,nequ33
mov a,74h
cjne a,26h,nequ33
mov a,75h
cjne a,27h,nequ33
mov a,76h
cjne a,28h,nequ33
setb 20h.3 到闹钟设置时间,使能闹钟报警标志位
nequ33:
pop acc
ret
sound:
acall h_half check 是否半点?
jb 20h.1,s23 半点则返回
jb 20h.0,s23
mov r1,#73h
mov a,74h
swap a
xchd a,@r1
cjne a,#59h,s25
xchd a,@r1
mov r1,#71h
mov a,72h
swap a
xchd a,@r1
s20: cjne a,#56h,s21
ajmp s26
s21: cjne a,#58h,s22
ajmp s26
s22: cjne a,#59h,s25
setb tr0
ajmp s26
s25: xchd a,@r1
s23: ret
s26: jb 20h.0,s25
setb tr0
xchd a,@r1
ret
T0中断服务程序,报时铃音信号输出
bz: djnz 64h,rrr
jb 20h.3,alarmsign闹钟到点报时有效
jb 20h.1,next 半点报时
mov 64h,#40.5KHZ
ajmp justh
alarmsign:
mov 64h,#1 2KHZ信号
justh:
djnz 66h,ccc
mov 66h,#100
djnz 65h,ccc产生1000次中断后关中断
mov 65h,#5 响0.5秒
setb 20h.0
clr tr0
reti
next:mov 64h,#2 1KHZ信号,半点报时音
ccc: jb 20h.3,cc
cpl p1.4 半点报时输出声音信号
rrr: reti
cc: cpl p1.4 闹钟报时输出声音信号
reti
T1中断服务程序,定时器主时钟
t1int:
clr ea
mov tl1,trr
mov th1,#3ch
djnz r3,sd 20*50MS=1S
mov r3,#20
cpl p1.4
inc 79h
clr 20h.0
clr 20h.1 半点报时标志清零
jb 20h.3,sdd 闹钟CHECK有效与否?
clr tr0关T0
sd: setb ea
reti
sdd: setb tr0 开T0,即开闹铃声音
setb ea
reti
显示子函数
dispnum1: 显示
ajmp disp_num
disp:
push acc
jb 20h.5,dispnum1开/关闹钟设置中界面...........
jb 20h.2,alarmcheck闹钟设置时间中界面..........
jb psw.5,closedisp
mov r2,#01h位选通信号输出到P2口
mov r5,#2 显示的位数循环控制
mov r0,#73h分别取出内存76H-71H
cjne r3,#10,dot1在小时和分之间闪烁DOT point
dot1:jnc dsp1
orl 73h,#10h
dot1:cjne r3,#11,dsp1
anl 73h,#0efh
dsp1:mov a,r2
cpl a
mov p2,a
mov a,@r0
dsp2:mov dptr,#bcd
movc a,@a+dptr
mov p0,a
acall delay
mov a,r2
rl a
mov r2,a
inc r0
djnz r5,dsp1
anl 73h,#0efh
pop acc
ret
closedisp: 关显示
acall delay
mov p0,#0ffh
mov p2,#0
pop acc
ret
闹钟的定时设置显示
alarmcheck:
mov r2,#01h
mov r5,#2 两位显示22-21H对应定时设置值
mov r0,#21h
dsp21:
mov a,r2
cpl a
mov p2,a
mov a,@r0
mov dptr,#bcd
movc a,@a+dptr
mov p0,a
acall delay
mov a,r2
rl a
mov r2,a
inc r0
djnz r5,dsp21
pop acc
ret
bcd:共阳接法数码管段码表
db 0c0h,0f9h,0a4h,0b0h
db 99h,92h,82h,0f8h
db 80h,90h,88h,83h
db 0c6h,0a1h,86h,8eh不带小数点七段
db 40h,79h,24h,30h,19h
db 12h,02h,78h,00h,10h
db 0ffh,0bfh,7fh,3fh带小数点七段
delay:mov r6,#4h
tm: mov r4,#0h
ee: djnz r4,ee 延时2048US=2MS
djnz r6,tm
ret
send:mov r7,#9 初始化设置
mov r0,#71h
mov a,#0h
ss: mov @r0,a
inc r0
djnz r7,ss
mov 78h,#1h
mov 77h,#01ah
mov 71h,#1
mov 72h,#2
mov 73h,#3
mov 74h,#4
ret
send1:初始化
mov r7,#10
mov r0,#20h
mov a,#0
ss1: mov @r0,a
inc r0
djnz r7,ss1
ret
开/关闹钟界面显示
disp_num:
mov p2,#0f7h
mov a,29h当前要 *** 作的闹钟号码
mov dptr,#bcd
movc a,@a+dptr
mov p0,a
acall delay
pop acc
ret
key_scanf: 按钮处理
push acc
mov 70h,#0
orl p1,#0fh
mov a,p1
cpl a
anl a,#07h
jz nokey1
acall daa
acall disp
mov a,p1
cpl a
anl a,#07h
jz nokey1
mov 70h,a
key_wait: 等按钮放下
acall daa
acall disp
mov a,p1
cpl a
anl a,#07h
jnz key_wait
mov a,70h
jnb acc.1,nokey1
cpl psw.5
nokey1: 无按钮
pop acc
ret
a_on_off:
jnb 29h.0,iii
cpl 20h.6
iii: jnb 29h.1,out_2
cpl 20h.7
out_2:
ajmp alarmnum
alarmnum:
setb 20h.5
acall daa
acall disp
acall key_scanf
clr 20h.5
mov a,70h
jb acc.0,a_on_off
jb acc.1,alar_adj_1
jb acc.2,a_num_inc
acall numb
ajmp alarmnum
alarm1_set:
push acc
mov a,70h
jb acc.1,alarmnum
alarm1_out:
clr 20h.2
pop acc
ret
a_num_inc:
inc 29h
mov a,29h
anl a,#0fh
cjne a,#3,alarmnum
anl 29h,#0
ajmp alarmnum
alar_adj_1:
setb 20h.2
acall daa
orl 21h,#10h
acall disp
anl 21h,#0fh
acall key_scanf
mov a,70h
jb acc.1,hadj_1
jb acc.2,minc_1
ajmp alar_adj_1
madj_2:
acall daa
orl 25h,#10h
acall disp
anl 25h,#0fh
acall key_scanf
mov a,70h
jb acc.1,hadj_2
jb acc.2,minc_2
ajmp madj_2
hadj_1:
acall daa
orl 23h,#10h
acall disp
anl 23h,#0fh
acall key_scanf
mov a,70h
jb acc.1,madj_2
jb acc.2,hinc_1
ajmp hadj_1
hadj_2:acall daa
orl 27h,#10h
acall disp
anl 27h,#0fh
acall key_scanf
mov a,70h
jb acc.1,alarm1_out
jb acc.2,hinc_2
ajmp hadj_2
minc_1:
inc 21h
mov r1,#21h
cjne @r1,#10,alar_adj_1
mov 21h,#0
inc 22h
mov r1,#22h
cjne @r1,#6,alar_adj_1
mov 22h,#0h
ajmp alar_adj_1
minc_2:
inc 25h
mov r1,#25h
cjne @r1,#10,madj_2
mov 25h,#0
inc 26h
mov r1,#26h
cjne @r1,#6,madj_2
mov 26h,#0
ajmp madj_2
hinc_1:
inc 23h
mov r1,#23h
cjne @r1,#10,ss14
mov 23h,#0
inc 24h
ss14:
mov a,24h
swap a
xchd a,@r1
cjne a,#ts,ss15
mov 23h,#0
mov 24h,#0
ajmp hadj_1
ss15:xchd a,@r1
ajmp hadj_1
hinc_2:
inc 27h
mov r1,#27h
cjne @r1,#10,sss14
mov 27h,#0
inc 28h
sss14:
mov a,28h
swap a
xchd a, @r1
cjne a,#ts,sss15
mov 27h,#0
mov 28h,#0
ajmp hadj_2
sss15:
xchd a,@r1
ajmp hadj_2
时间调整程序
time_adj:
clr psw.5
push acc
mov a,70h
jb acc.0,l1P1.0调时功能键,每按一次切换一位
ajmp nokeyout
adj_out:
mov 21h,73h
mov 22h,74h
setb p3.0 闭合继电器
setb tr1
nokeyout:
pop acc
ret
QQ: anl 73h,#0fh
anl 74h,#0fh
anl 78h,#0fh
ret
l1: clr tr1acall dab 分钟调整
orl 73h,#10h点亮分右下角的小数点,当前调整位置
acall disp
acall QQ
acall key_scanf
clr psw.5
mov a,70h
jb acc.0,h_adj切换到小时调整
jb acc.1,m_incP1.2加1按钮
ajmp l1
h_adj: 小时调整
acall dab
orl 74h,#10h
acall disp
acall QQ
acall key_scanf
clr psw.5
mov a,70h
jb acc.0,out_adj切换到星期调整
jb acc.1,h_inc小时加1
ajmp h_adj
w_adj:
acall daa
orl 78h,#10h
acall disp
acall QQ
acall key_scanf
clr psw.5
mov a,70h
jb acc.0,out_adj
jb acc.2,w_inc
ajmp w_adj
out_adj:
ajmp adj_out
m_inc:调整分时,对定时复位,初始化
clr tr1
mov 71h,#0
mov 72h,#0
mov 79h,#0
mov tl1,trr
mov th1,#3ch
mov r3,#20
inc 73h
mov r1,#73h
cjne @r1,#10,s12
mov 73h,#0
inc 74h
mov r1,#74h
cjne @r1,#10,s12
mov 74h,#0
s12: ajmp l1
调整小时位
h_inc:
inc 74h
mov r1,#74h
cjne @r1,#10,s14
mov 74h,#0
inc 76h
s14: ajmp h_adj
mov a,76h
swap a
xchd a,@r1
cjne a,#ts,s1512进制,24进制设置值决定
mov 75h,#0
mov 76h,#0
ajmp h_adj
s15: xchd a,@r1
ajmp h_adj
调整星期位
w_inc:
inc 78h
mov r1,#78h
cjne @r1,#8,s16
mov 78h,#1h
s16: ajmp w_adj
当前闹钟开/关情况报告位
numb:clr 29h.4
jnb 29h.0,iii1
jnb 20h.6,iii1
setb 29h.4
iii1:jnb 29h.1,out_21
jnb 20h.7,out_21
setb 29h.4
out_21:
jnb 20h.6,out_12
jnb 20h.7,out_13
mov 77h,#1dh
ajmp out_22
out_12:
jnb 20h.7,out_14
mov 77h,#1bh
ajmp out_22
out_13:
mov 77h,#1ch
ajmp out_22
out_14:
mov 77h,#1ah
out_22:
ret
end
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)