四、注意事项
1、 当MCU用6MHz晶振时,工作电压可在2.6-5.5V之间。
2、 外接继电器,请注意工作电压,及晶体管的保护。
;***************
;timer_program 2000-12-3 倒计时器源程序
;***************
timers equ 08h
;******************************************
al1_min equ timers+1h
al1_hour equ timers+2h
al2_min equ timers+3h
al2_hour equ timers+4h
al3_min equ timers+5h
al3_hour equ timers+6h
flash equ timers+7h
;***********************************
del1 equ flash+1h
del2 equ flash+2h
del3 equ flash+3h ;ram addres at 12h
;************************************
key_data equ del3+1h
sec equ del3+2h
timer_no equ sec+1h
del4 equ timer_no+1h
key_power equ del4+1h
;*************************************
time_led1 equ 24h
time_led2 equ time_led1+1
time_led3 equ time_led2+1
led1 equ time_led3+1h
led2 equ led1+1
led3 equ led2+1
;**********************************
al1_min_t equ led3+1
al1_hour_t equ al1_min_t+1
al2_min_t equ al1_hour_t+1h
al2_hour_t equ al2_min_t+1h
al3_min_t equ al2_hour_t+1h
al3_hour_t equ al3_min_t+1h
;***************************************
beep_timer equ al3_hour_t+1h
;****************以上进行内存分配*********
led_1 bit p3.0;P3.0控制最右边的数码管
led_2 bit p3.1;P3.1控制中间的数码管
led_3 bit p3.7;P3.7控制最左边的数码管
;(原理图标的好象有出入,以PCB为准,最左边的数码管是颠反安装的)
HA BIT P3.2;接蜂鸣器
key_f bit p3.3;接按钮公共端
pnp1 bit p3.4;T1路控制输出
pnp2 bit p3.5;T2路控制输出
timer_50ms bit 00h;定时50毫秒标志位
timer_1s bit 01h;定时1秒标志位
timer_3s bit 03h;定时3秒标志位
; timer_20s bit 04h;定时20秒标志位
timer_1min bit 05h;定时1分钟标志位
timer_10min bit 06h;定时10分钟标志位
;timer_am bit 07h
key_set_f bit 08h
sec_flash_f bit key_set_f+1h
;************************************
al1_f bit sec_flash_f+1h
al2_f bit al1_f+1h
al3_f bit al2_f+1h
flash_f bit al3_f+1h
set_f bit flash_f+1h
;***********************************
al_f bit set_f+1h
al_out_f bit al_f+1h
all_s bit al_f+2h
turn_f bit all_s+1h
aal1_f bit turn_f+1h
aal2_f bit turn_f+2h
aal3_f bit turn_f+3h
;**********************************
tih equ 3ch ;9e58h 6MHz
til equ 0b0h ;3cb0h 12MHz
tis equ 10d ;20d 12MHz, 10d 6MHz
ti_no equ 3h
led_blk equ 0ah
led_c equ 0bh
led_e equ 0ch
;主程序开始
oRG 0000H; ;
sJMP start
ORG 0003H; ;
reti;
ORG 000BH ;
reti ;
ORG 0013H
reti ;
ORG 001BH ;
aJMP T1 ;
ORG 0023H ;
RETI; AJMP RS_485 ;
;**************************************
start:
MOV R7,#78h ;
MOV R0,#10H ;
CLR A ;
CR: INC R0 ;
MOV @R0,A ;
djnz r7,cr ;将内存清零
MOV SP,#40H ;
clr ea
clr set_f
clr turn_f
setb pnp2
setb pnp1
;********************************* j al1-3 data
mov r0,#al1_min
mov r1,#al1_min_t
mov r7,#07h
op_4:
mov a,@r0
cjne a,#19d ,op_1
op_2: mov a,#00h
mov @r0,a
sjmp op_3
op_1:
jnc op_2
op_3:
mov a,@r0
mov @r1,a
inc r0
inc r1
djnz r7 ,op_4
mov a,flash
mov c,acc.1 ;acc.1 al1 acc.2 al2 ....
mov al1_f,c
mov c,acc.2 ;acc.1 al1 acc.2 al2 ....
mov al2_f,c
mov c,acc.3 ;acc.1 al1 acc.2 al2 ....
mov al3_f,c