新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > LED單片機(jī)定時(shí)鬧鈴程序

LED單片機(jī)定時(shí)鬧鈴程序

作者: 時(shí)間:2012-12-31 來源:網(wǎng)絡(luò) 收藏

ConvertoBuffer:
MOV R1,#30H
JB ClockMode,DispAlarmSet
MOV A,Second;
MOV DispSecond,A;
MOV A,Minute;
MOV Dispminute,A;
MOV A,Hour;
MOV DispHour,A
AJMP Convert
DispAlarmSet:
JB AlarmOnOff,AlarmOn
MOV DispSecond,#00H
AJMP Next
AlarmOn:
MOV DispSecond,#11
Next:
MOV A,AlarmMinute
MOV Dispminute,A
MOV A,AlarmHour
MOV DispHour,A
Convert:
MOV A,DispSecond
MOV B,#10
DIV AB
MOV @R1,B
INC R1
MOV @R1,A
INC R1
MOV A,DispMinute
MOV B,#10
DIV AB
MOV @R1,B
INC R1
MOV @R1,A
INC R1
MOV A,DispHour
MOV B,#10
DIV AB
MOV @R1,B
INC R1
MOV @R1,A
RET
;*************************************
; 鬧時(shí)設(shè)置子程序
;*************************************
AlarmSet:
JNB K1,$
LCALL Delay
CheckArmMinuteKey:
JB K3,CheckArmHourKey
CL1: SETB AlarmOnOff
MOV A,AlarmMinute
ADD A,#1
MOV AlarmMinute,A
CJNE A,#60,ArmNotOver1
MOV AlarmMinute,#0
ArmNotOver1:
JNB K3,$
CheckArmHourKey:
JB K2,AlarmSetEnd
SETB AlarmOnOff
MOV A,AlarmHour
ADD A,#1
MOV AlarmHour,A
CJNE A,#24,ArmNotOver2
MOV AlarmHour,#0
ArmNotOver2:
JNB K2,$
JB K3,AlarmSetEnd
ACALL CL1
AlarmSetEnd:
JB K1,AlarmSet
JNB K1,$
CLR ClockMode
RET
;**************************************
; 鬧時(shí)服務(wù)子程序
;**************************************
LOOP:
CLR P1.7
ACALL Delay1
SETB P1.7
JB K1,LOOP
JNB K1,$
CLR AlarmOnOff
CLR AlarmTimeOn
AlarmReturn: RET
;**************************************
; 延時(shí)子程序
;**************************************
DELAY1: MOV R3,#15
LOOP1: MOV R5,#90
NOP
LOOP2: DJNZ R5,LOOP2
DJNZ R3,LOOP1
RET
Delay:
MOV R6,#05H
Del:
MOV R7,#08Fh
DJNZ R7,$
DJNZ R6,Del
RET
END

這個(gè)程序到這里就完畢了,再來一個(gè)簡(jiǎn)單一點(diǎn)的程序,不過不帶led顯示,定時(shí)1秒,要其他時(shí)間自己修改R0和R1的就可以了。
ORG 0000H
;LJMP MAIN
;ORG 0030H
;MAIN:MOV SP,#60H
MOV TMOD,#02H
MOV TL0,#06H
MOV TH0,#06H
MOV R0,#100
MOV R1,#20
SETB TR0
WAIT:JNB TF0,$
CLR TF0
DJNZ R1,WAIT
MOV R1,#20
DJNZ R0,WAIT
MOV R0,#100
CPL P1.0
AJMP WAIT
END


上一頁 1 2 下一頁

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉