电子制作天地网站欢迎您的光临,欢迎提出宝贵意见或建议。本站信息产业部备案: 粤ICP备05114582号
采用AT89C2051制作的智能时钟
Smart Clock

时间:2008-1-1 12:42:18 来源:佚名 作者:未知 编辑: 【关闭


采用AT89C2051制作的智能时钟,Smart Clock

关键字:电子钟,89C2051,单片机

;2001.5.24
;***************
;all_clk1 _program 2000-10-12
;***************
fl_250ms bit 00h
fl_500ms bit fl_250ms+1
set_clk_f bit fl_500ms+1
set_al4_f bit set_clk_f+1
am_f bit set_al4_f+1
fl_3s bit am_f+1
al1_f bit fl_3s+1
al2_f bit fl_3s+2
al3_f bit fl_3s+3
al4_f bit fl_3s+4
set_over bit al4_f+1
ha_f bit set_over+1
ha_over bit ha_f+1
fl_ms_f bit ha_over+1
fl_s_f bit fl_ms_f+1
key_over bit fl_s_f+1
;**************************************************
key_data equ 08h
timers equ key_data+1
t_30ms equ timers+1
t_20ms equ t_30ms+1
t_1s equ t_20ms+1
k1_data equ t_1s+1
k2_data equ k1_data+1
stat_work equ k2_data+1
stat_led equ stat_work+1
t_1ms equ stat_led+1
t_20m equ t_1ms+1
beep equ t_20m
al1 equ beep+1
al2 equ beep+2
al3 equ beep+3
al4 equ beep+4
al5 equ beep+5
al6 equ beep+6
al7 equ beep+7
al8 equ beep+8
ret_timer equ al8+1
;**************************************************
sec equ 23h
min equ sec+1h
hour equ min+1h
day equ hour+1h
mon equ day+1h
year equ mon+1h
w_adj equ year+1h
week equ w_adj+1h
;***************************************
al1_h equ week+1h
al1_m equ al1_h+1h
al2_h equ al1_m+1h
al2_m equ al2_h+1h
al3_h equ al2_m+1h
al3_m equ al3_h+1h
al4_h equ al3_m+1h
al4_m equ al4_h+1h
al5_h equ al4_m+1h
al5_m equ al5_h+1h
al6_h equ al5_m+1h
al6_m equ al6_h+1h
al7_h equ al6_m+1h
al7_m equ al7_h+1h
al8_h equ al7_m+1h
al8_m equ al8_h+1h
beep_t equ al8_m+1
frist equ beep_t+1
;**************************************
led1 equ frist+1
led2 equ led1+1
led3 equ led2+1
led4 equ led3+1
led5 equ led4+1
sp_data equ led5+1
;**************************************
led_1 bit p3.5
led_2 bit p3.4
led_3 bit p3.3
led_4 bit p3.2
led_5 bit p3.1

beep_f BIT P3.7
key_f bit p3.0

;********************************************************
t_h_100ms equ 05dh ;100 ms for 6MHz
t_l_100ms equ 07fh ;c6 for 100ms
timer_no equ 8d ;3c90+30d=3cb0h
w_adj_dat equ 50d
key_da equ 00000110b

;*********************************************************
blk_led equ 20d
dot_led equ 21d
f_led equ 22d
n_led equ 23d
u_led equ 24d
t_led equ 25d
b_led equ 26d
d_led equ 27d


oRG 0000H; ;
sJMP start
ORG 0003H; ;
reti;
ORG 000BH ;
;ajmp t0
reti ;
ORG 0013H
reti ;
ORG 001BH ;
aJMP T1 ;
ORG 0023H ;
RETI; AJMP RS_485 ;

;**************************************
start:
call clr_ram
MOV SP,#sp_data ;
call int_t0
call timer_int
call timer_20ms
STAR_BI:
call clock
call week_auto
call al_out
CALL KEY_bord
call key_del
call set_clk_al
call key_jmp
call reback
call led_jmp
sjmp star_bi
;*******************************************
reback:
mov a,stat_work
jz reback_end
jb al1_f ,ka1
mov ret_timer,sec
setb al1_f
sjmp reback_end
ka1:
mov a,ret_timer
add a,#05d
mov b,#60d
div ab
mov a,sec
cjne a,b,reback_end
clr al1_f
mov stat_work,#00d
reback_end:
ret
key_jmp:
mov a,key_data
jz key_jmp_end
mov ret_timer,sec
cjne a,#01d,kk1
mov a,stat_work
inc a ;k1_key
cjne a,#9d,kka1
mov a,#00d
kka1:
mov stat_work ,a
sjmp key_jmp_end
kk1:
mov a,stat_work ;k2_key
jnz kk2
mov a,stat_led
inc a
cjne a,#05d,kka2
mov a,#00d
kka2:
mov stat_led,a
sjmp key_jmp_end
kk2:
acall all1
cpl a
mov @r0,a
key_jmp_end:
ret

all1:
mov r0,#al1
mov a,stat_work
dec a
add a,r0
mov r0,a
mov a,@r0
ret

led_jmp:
;**********************************
;mov stat_work,#01d
;mov stat_tw,#01d

mov a,stat_work
jnz led_al1
mov a,stat_led
acall led_t_d
mov led1,week
sjmp led_jmp_end
led_al1:
acall all1
mov led1,#f_led
jnz le_t2
mov led1,#n_led
le_t2:
jb fl_250ms ,le_t4
mov led1,#blk_led
le_t4:
acall al_led
led_jmp_end:
acall led
ret
;*************************************

time_24:
mov a,hour
acall bcd_8
mov led2,a
jnz tim4
mov led2,#blk_led
tim4:
mov led3,b
jb fl_500ms,tim1
mov a,b
add a,#10d
mov led3,a
tim1:
acall led_min
time_12_end:
ret
;***********************************
led_min:
mov a,min
acall bcd_8
jb fl_500ms ,tim2
add a,#10d
tim2:
mov led4,a
mov led5,b
ret
;*************************************


date_led:
mov a,mon
acall bcd_8
mov led2,a
jnz da1
mov led2,#blk_led
da1:
mov a,b
add a,#10d
mov led3,a
mov a,day
acall bcd_8
mov led4,a
jnz da2
mov led4,#blk_led
da2:
mov led5,b
date_led_end:
ret

;*************
; D_8=>BCD
;*************
BCD_8:
MOV B,#10D
DIV AB
RET
;****************************************
LED:
mov p1,#0
mov dptr,#led_asc
;***************************led1
mov a,led1
movc a,@a+dptr
mov p1,a
clr led_1
acall timer_1ms
acall timer_1ms
;acall timer_1ms
;acall timer_1ms
;acall timer_1ms

setb led_1
;*************************led2
led_led2:
mov a,led2
movc a,@a+dptr
mov p1,a
clr led_2
acall timer_1ms
setb led_2
;*************************led3
led_led3:
mov a,led3
movc a,@a+dptr
mov p1,a
clr led_3
acall timer_1ms
setb led_3
;*************************led4
led_led4:
mov a,led4
movc a,@a+dptr
mov p1,a
clr led_4
acall timer_1ms
setb led_4
;*************************led5
led_led5:
mov a,led5
movc a,@a+dptr
mov p1,a
clr led_5
acall timer_1ms
setb led_5
;*************************
led_end:
mov p1,#0
ret
;************************************
; bafhcdeg
led_asc:
db 11101110B;0
db 10001000B;1
db 11000111B;2
db 11001101B;3
db 10101001B;4
db 01101101B;5
db 01101111B;6
db 11001000B;7
db 11101111B;8
db 11101101B;9
db 11111110B;0. =>10d
db 10011000B;1.
db 11010111B;2.
db 11011101B;3.
db 10111001B;4.
db 01111101B;5.
db 01111111B;6.
db 11011000B;7.
db 11111111B;8.
db 11111101B;9.
DB 00000000B;BLACK=>20d
DB 00010000B;dot=>21d
DB 00100110b;l=>22d
dB 10101011B;h=>23d
DB 10101110B;u=>24d
DB 00100111B;t=>25d
dB 00101111B;b=>26d
dB 10001111B;d=>27d

; bafhcdeg

;**********************************
;delay
;********************************
timer_1ms:
mov t_1ms,#030h
r2_1:
djnz t_1ms , r2_1
ret
timer_20ms:
mov t_20m,#050d
r2_2:
call clock
call led
djnz t_20m , r2_2
call week_auto
call al_out
ret
;#############################################
;if mon<=2 and year=4Z(0,1,2,3...)
;gs1=>week=mod([5/4]*year+mon_asc(mon)+day-1)/7
;else
; gs2=>week=mod([5/4]*year+mon_asc(mon)+day)/7
week_auto:

mov a,YEAR
mov b,#05
mul ab
mov r4,b
mov r5,a
mov r7,#04
call mul_2

MOV DPTR,#MON_ASC
MOV A,MON
dec a
MOVC A,@A+DPTR
ADD A,r3
;*********************
MOV B,DAY
ADD A,B
mov r3,a;r3=gs2
;*******jb mon<=2 ******
MOV A,MON
CJNE A,#02D,WEEK_1
SJMP WEEK_2
WEEK_1:
JC WEEK_2
week_3:
mov a,r3
mov b,#07
div ab
mov a,b
sjmp week_4
WEEK_2:
;*****jb year=4N ******
mov a,year
mov b,#04
div ab
mov a,b
jnz week_3
mov a,r3
dec a
mov b,#07
div ab
mov a,b
week_4:
MOV WEEK,a
jnz week_end
mov week,#07h
week_end:
RET
MON_ASC:
DB 6d, 2d, 2d, 5d, 0d, 3d, 5d, 1d, 4d, 6d, 2d, 4d ;2002.5.5
;r4r5/r7=r3
mul_2:
D457: CLR C
MOV A,R4
SUBB A,R7
JC DV50
SETB OV
RET
DV50: MOV R6,#8 ;;求平均值(R4R5/R7-→R3)
DV51: MOV A,R5
RLC A
MOV R5,A
MOV A,R4
RLC A
MOV R4,A
MOV F0,C
CLR C
SUBB A,R7
ANL C,/F0
JC DV52
MOV R4,A
DV52: CPL C
MOV A,R3
RLC A
MOV R3,A
DJNZ R6,DV51
MOV A,R4 ;;四舍五入
ADD A,#0;R4
JC DV53
SUBB A,R7
JC DV54
DV53: INC R3
DV54: CLR OV
RET
;*************************************************************
clr_ram:
MOV R7,#78h ;
MOV R0,#0bH ;
CLR A ;
CR: INC R0 ;
MOV @R0,A ;
djnz r7,cr ;CLR RAM
ret
;************** INT_CTRL
int_t0:
setb et1
MOV TMOD,#00010001b ;
mov w_adj,#w_adj_dat
setb ea
jmp adj_w
;**********************************************
al_led:
mov r0,#al1_h
mov a,stat_work
dec a
rl a
add a,r0
mov r0,a
mov a,@r0
acall bcd_8
mov led2,a
jnz al_1
mov led2,#blk_led
al_1:
mov a,b
add a,#10d
mov led3,a
inc r0
mov a,@r0
acall bcd_8
add a,#10d
mov led4,a
mov led5,b
al_led_end:
ret

;********************************
set_clk_al:
jnb set_clk_f,see1
call set_clock
clr set_clk_f
sjmp see2
see1:
jnb set_al4_f,see2
call set_al4
clr set_al4_f
see2:
ret
;*********************************
proc led_t_d
led_t_d:
mov dptr,#led_ord_3
mov b,#02h
mul ab
jmp @a+dptr

led_ord_3: ajmp led_k0_2
ajmp led_k1_2
ajmp led_k2_2
ajmp led_k3_2
ajmp led_k4_2

led_k0_2: ; timer_12 and date to led
acall time_12
jnb fl_3s ,lk1
acall date_led
lk1:
ajmp led_jmp_5_end
led_k1_2: ; timer_12 to led
acall time_12
ajmp led_jmp_5_end
led_k2_2: ;timer_24and date to led
acall time_24
jnb fl_3s ,lk2
acall date_led
lk2:
ajmp led_jmp_5_end
led_k3_2: ;timer_24to led
acall time_24
ajmp led_jmp_5_end

led_k4_2: ;sec to led
mov led1,#blk_led
mov led2,#blk_led
mov led3,#dot_led
mov a,sec
acall bcd_8
add a,#10d
mov led4,a
mov led5,b
led_jmp_5_end:
ret
end

;****************************************
proc set_al4
set_al4:
mov k1_data,#01d
mov k2_data,#01d
clr set_over
acall led_al
acall key_bord
call sf_key
mov key_data,#0
mov frist,#0
set_al41:

call clock
call week_auto
acall led_al
acall key_bord
call key_del
acall key_al
jnb set_over,set_al41
clr a
mov k1_data,a
mov k2_data,a
mov key_data,a
mov frist,a
ret
end
;**************************************
proc key_al
key_al:
mov a,key_data
jz key_al_end
cjne a,#01d,k2_al

inc k1_data ;(1-9)
mov a,k1_data
cjne a,#19d,key_al_end
mov k1_data,#01d
sjmp key_al_end


k2_al:
mov a,k1_data
cjne a,#018d,ke2
setb set_over
sjmp key_al_end
ke2:
mov r0,#al1_h
dec a
add a,r0
mov r0,a
inc @r0
acall jj_bit
mov b,#24d
jnz ke3
mov b,#60d
ke3:
mov a,@r0
div ab
mov a,b
mov @r0,a
key_al_end:
ret
end
jj_bit:
mov a,k1_data
mov b,#02d
div ab
mov a,b ;(a=1,0)
ret
;*********************************
led_out1:
mov led2,#00h
mov led3,#u_led
mov led4,#t_led
mov led5,#blk_led
mov led1,#blk_led
ret
;********************************
led_al:
mov a,k1_data
cjne a,#017d,lo1
acall beep_timer
sjmp led_al_end
lo1:
cjne a,#18d,ld1
acall led_out1
sjmp led_al_end
ld1:
inc a
mov b,#02d
div ab
;**********
mov led1,a
;**********
dec a
rl a
mov r0,#al1_h
add a,r0
mov r0,a
mov a,@r0
acall bcd_8
mov led2,a
jnz ld2
mov led2,#blk_led
ld2:
mov a,b
add a,#10d
mov led3,a
;************************************
inc r0
mov a,@r0
acall bcd_8
add a,#10d
mov led4,a
mov led5,b

;***************************flash bit
jb fl_250ms,led_al_end
acall jj_bit
jnz led_al_e
mov led4,#blk_led
mov led5,#blk_led
sjmp led_al_end
led_al_e:
mov led2,#blk_led
mov led3,#blk_led
led_al_end:
acall led
ret
;***************************************
proc set_clock
set_clock:
mov k1_data,#01d
mov k2_data,#01d
clr set_over
call led_cl
call key_bord
call sf_key
mov key_data,#0
mov frist,#0
set_al41:
call clock
acall week_auto
call al_out
acall led_cl
acall key_bord
call key_del
acall key_cl
jnb set_over,set_al41
;acall key_bord
clr a
mov k1_data,a
mov k2_data,a
mov key_data,a
mov frist,a
ret
end
;**************************************
proc key_cl
key_cl:
mov a,key_data
jz key_al_end
cjne a,#01d,k2_al

inc k1_data ;(1-8)
mov a,k1_data
cjne a,#9d,key_al_end
mov k1_data,#01d
sjmp key_al_end
k2_al:
mov a,k1_data
cjne a,#08d,ke2
setb set_over
sjmp key_al_end
ke2:
dec a
mov dptr,#asc_h
movc a,@a+dptr
mov b,a
;********************************
mov r0,#sec
mov a,k1_data
dec a
add a,r0
mov r0,a
inc @r0
mov a,@r0
div ab
mov a,b
mov @r0,a
key_al_end:
ret
end
asc_h:
db 60d,60d,24d,32d,13d,100d,100d

proc led_cl
led_cl:
mov dptr,#led_ord_3
mov a,k1_data
dec a
mov b,#02h
mul ab
jmp @a+dptr
led_ord_3: ajmp led_k0_2
ajmp led_k1_2
ajmp led_k2_2
ajmp led_k3_2
ajmp led_k4_2
ajmp led_k5_2
ajmp led_k6_2
ajmp led_k7_2

led_k0_2: ; led sec
mov led2,#blk_led
mov led3,#dot_led
mov a,sec
acall bcd_8
add a,#10d
mov led4,a
mov led5,b
jb fl_250ms ,lk1
mov led4,#blk_led
mov led5,#blk_led
lk1:
ajmp led_jmp_5_end
led_k1_2: ; led min,hour
acall led_hour
jb fl_250ms ,lk2
mov led4,#blk_led
mov led5,#blk_led
lk2:
ajmp led_jmp_5_end
led_k2_2: ;led min,hour
acall led_hour
jb fl_250ms ,lk3
mov led2,#blk_led
mov led3,#blk_led
lk3:
ajmp led_jmp_5_end
led_k3_2: ;led day,mon
acall led_mon
jb fl_250ms ,lk4
mov led4,#blk_led
mov led5,#blk_led
lk4:
ajmp led_jmp_5_end
led_k4_2: ; led day,mon
acall led_mon
jb fl_250ms ,lk5
mov led2,#blk_led
mov led3,#blk_led
lk5:
ajmp led_jmp_5_end
led_k5_2: ; led year
mov led2,#2d
mov led3,#0d
mov a,year
acall bcd_8
mov led4,a
mov led5,b
jb fl_250ms ,lk6
mov led4,#blk_led
mov led5,#blk_led
lk6:
ajmp led_jmp_5_end
led_k6_2: ;led w_adj
mov led2,#d_led
mov led3,#blk_led
mov a,w_adj
acall bcd_8
mov led4,a
mov led5,b
jb fl_250ms ,lk7
mov led4,#blk_led
mov led5,#blk_led
lk7:
ajmp led_jmp_5_end
led_k7_2: ;led out
acall led_out1
led_jmp_5_end:
mov led1,week
acall led
ret
end

led_hour:
mov a,hour
acall bcd_8
mov led2,a
jnz lj1
mov led2,#blk_led
lj1:
mov a,b
add a,#10d
mov led3,a
;*********************
mov a,min
acall bcd_8
add a,#10d
mov led4,a
mov led5,b
ret
led_mon:
mov a,mon
jnz lj5
inc mon
mov a,mon
lj5:
acall bcd_8
mov led2,a
jnz lj2
mov led2,#blk_led
lj2:
mov led3,b
;*********************
mov a,day
jnz lj4
inc day
mov a,day
lj4:
acall bcd_8
mov led4,a
jnz lj3
mov led4,#blk_led
lj3:
mov led5,b
ret
;********************************************
al_out:
jb ha_over,al_out_end
mov r7,#8d
mov r1,#al8_m
al_ch_1:
mov r0,#min
mov r6,#02d ;min hour
al_l:
mov a,@r0
mov b,@r1
cjne a,b ,al_ch
inc r0
dec r1
djnz r6 ,al_l
;**************************************************
mov a,r7
dec a
mov r0,#al1
add a,r0
mov r0,a
mov a,@r0
mov c,acc.0
cpl c
anl c,fl_250ms
cpl c
mov beep_f,c
acall beep_out
al_ch:
clr c
mov a,r1
subb a,r6
mov r1,a
djnz r7,al_ch_1
al_out_end:
ret

beep_out:
jb ha_f,ba1
mov beep,sec
setb ha_f
ba1:
mov a,beep
add a,beep_t
mov b,#60d
div ab
mov a,sec
cjne a,b,beep_out_end
setb beep_f
setb ha_over
clr ha_f
beep_out_end:
ret
timer_int:
MOV T_1S,#TIMER_no
mov beep_t,#15d
mov year ,#01d
mov mon , #011d
mov day , #06d
mov hour ,#13d
mov min , #00d
mov sec , #00d
mov r7,#16
mov dptr ,#al_asc
mov r0,#al1_h
al_read:
clr a
movc a,@a+dptr
mov @r0,a
inc r0
inc dptr
djnz r7,al_read
ret

;************************************
beep_timer:
mov led1,#blk_led
mov led2,#b_led
mov led3,#blk_led
mov a,beep_t
acall bcd_8
mov led4,a
mov led5,b
jb fl_250ms,ft1
mov led4,#blk_led
mov led5,#blk_led
ft1:
ret

time_12:
mov dptr,#asc_12
mov a,hour
rl a
movc a,@a+dptr
mov led2,a
jnz iu2
mov led2,#blk_led
iu2:
inc dptr
mov a,hour
rl a
movc a,@a+dptr
jb fl_500ms ,iu1
add a,#10d
iu1:
mov led3,a

;*************************************** min to led
acall led_min
time_24_end:
ret
asc_12:
db 11d,2d,21d,1d,21d,2d,21d,3d,21d,4d,21d,5d,21d,6d,21d,7d
db 21d,8d,21d,9d,11d,0d,11d,1d
db 1d,2d,0d,1d,0d,2d,0d,3d,0d,4d,0d,5d,0d,6d,0d,7d,0d,8d,0d,9d
db 1d,0,1d,1d

clock:
;********************************
mov a,sec
cjne a,#60d,clock_end;!!!!!!!!!!!!!!!!!!!!!!
mov sec,#00h

inc min
;**********
clr ha_over ;2001.5.6

mov a,min
cjne a,#60d,clock_end
mov min,#00h

inc hour
mov a,hour
cjne a,#24d,clock_end
mov hour,#00h

mov a,mon
xrl a,#02d
jnz mm_1
mov dptr,#year_d
mov a, year
movc a,@a+dptr
sjmp mm_2
mm_1:
mov a,mon
dec a
mov dptr,#mou_12
movc a,@a+dptr
mm_2:
mov b,a
inc b
inc day ;***************day+1
mov a,day
cjne a ,b ,clck_end
sjmp clck1
clck_end:
jc clock_end
clck1:
mov day,#01h

inc mon
mov a,mon
cjne a,#13d ,clock_end
mov mon,#01d

inc year
mov a,year
cjne a,#100d ,clock_end
mov year,#00d
clock_end:
call fl_out
ret
mou_12:
db 31d, 28d, 31d, 30d, 31d,30d
db 31d, 31d, 30d,31d, 30d,31d

year_d:
db 29d, 28d, 28d, 28d, 29d, 28d , 28d, 28d, 29d, 28d
db 28d, 28d, 29d, 28d, 28d, 28d , 29d, 28d, 28d, 28d
db 29d, 28d, 28d, 28d, 29d, 28d , 28d, 28d, 29d, 28d
db 28d, 28d, 29d, 28d, 28d, 28d , 29d, 28d, 28d, 28d
db 'li jie 2000.5.15'
;***************************************
t1:
push a
push psw
push b
clr fl_ms_f
djnz t_1s ,t1_end
clr fl_s_f
inc sec
call adj_w
;********************************
t1_end:
pop b
pop psw
pop a
reti

adj_w:
clr tr1
mov a,#T_L_100ms
add a, w_adj ;*******have 5 order
mov tl1 ,a
mov a,#T_H_100ms
addc a, #00h
mov th1,a
mov t_1s,#timer_no
setb tr1
ret

fl_out:
jb fl_ms_f ,fl_out_end
setb fl_ms_f
mov a,t_1s
mov b,#02d
div ab
mov a,b
jnz to_d1
cpl fl_250ms
to_d1:
mov a,t_1s
mov b,#04d
div ab
mov a,b
jnz to_d2
cpl fl_500ms
to_d2:
fl_out_end:
call sec_out
ret

sec_out:
jb fl_s_f ,sec_out_end
setb fl_s_f
mov a,sec
mov b,#07d
jnb fl_3s,za1
mov b,#02d
za1:
div ab
mov a,b
jnz sec_out_end
cpl fl_3s
sec_out_end:
ret
;**********************************
key_del:
mov a,key_data
jnz kl_12
mov a,frist
jnz kl_13
ret
kl_13:
mov key_data,frist
mov frist,#0
clr key_over
jmp sf_beep
kl_12:
jnb key_over,kl11
mov a,t_30ms
add a,#03
mov b,#60d
div ab
mov a,sec
cjne a,b,key_del_end
clr key_over
jmp set_key
kl11:
mov t_30ms,sec
setb key_over
key_del_end:
call sf_a
cjne a,#key_da,sfg_12
clr key_over
jmp sf_beep
sfg_12:
mov frist,key_data
mov key_data,#0
ret
;****************************************
key_bord:
acall re_k
mov a,key_data
jz key_bord1_end
;acall psf_key0
key_bord1_end:
setb key_f
ret
set_key:
mov a,key_data
cjne a,#01h,set_cc1
setb set_al4_f
sjmp sf23
set_cc1:
cjne a,#02h,sf23
setb set_clk_f
sf23:
ret
;************************************
sf_key:
call clock
call week_auto
call al_out
setb key_f
call led
call sf_a
cjne a,#key_da,sf_key
call sf_beep
ret

sf_beep:

clr beep_f
call timer_20ms
setb beep_f
ret
;********************************
re_k:
mov key_data,#00h
mov p1,#00h
mov a,p3
orl a,#01111111b
mov p3,a
clr key_f
mov a,p3
setb key_f
mov p1,#0ffh
anl a ,#00000110b
cjne a,#00000110b,you_key
re_k_end:
ret
you_key:
call timer_20ms
;call led
mov p1,#00h
mov a,p3
orl a,#01111111b
mov p3,a
clr key_f
mov a,p3
setb key_f
mov p1,#0ffh
anl a ,#key_da
cjne a,#key_da,you_key1
ret;sjmp re_k_end
you_key1:
jb acc.1,key_kb
mov key_data,#02h
key_kb:
jb acc.2,sf_key0
mov key_data,#01h
sf_key0:
ret

sf_a:
mov p1,#00h
mov a,p3
orl a,#01111111b
mov p3,a
clr key_f
mov a,p3
setb key_f
anl a ,#key_da
ret
al_asc:
db 06d,40d, 06d,50d, 07d,00d, 07d,10d;am 4_al
db 07d,15d, 013d,40d, 13d,45d, 14d,15d;pm 4_al



◆相关文章◆
◆ 编辑推荐 ◆
用户:
更多评论
您要为您所发的言论的后果负责,故请各位遵纪守法并注意语言文明。60个字以内
留言:
验证码:

免责声明:
●本站所有内容均来自网络,以学习为目的,如果侵犯了您的利益,请来信告知,立即删除,站长邮件为"diy+dzdiy.com",请将"+"变更为"@"
●电子制作存在风险,请注意人身安全,如果您在根据本站电路进行制作过程中发生伤害,本站不负任何责任。

版权所有:www.dzdiy.com ? 2001-2019 本站信息产业部备案: 粤ICP备05114582号