;***************
;f_hz_program 2001.5.22
;***************
f_h equ 08h
f_l equ f_h+1
hz_number equ f_l+1
n1 equ hz_number+1
Hz bit p3.1
log bit p3.0
APP bit p3.5
l1 bit p1.0
l2 bit p1.1
l3 bit p1.2
;****************** main **********************
oRG 0000H; ;
JMP start
ORG 0003H; ;
reti
ORG 000BH ;
jmp t0
ORG 0013H
reti ;
ORG 001BH ;
cpl hz
reti
ORG 0023H ;
RETI
;**************************************
start:
MOV R1,#78h ;
MOV R0,#02H ;
CR: INC R0 ;
MOV @R0,#0 ;
djnz r1,cr
MOV SP,#22h
setB ET0 ;
setb ET1 ;
setb ea
MOV TMOD,#00100001B;T1=>8TT,T0=>16tT
;***************************************************
; MINI_Pragram
;***********************************************
START_BI:
cpl APP
call read_dip
call log_in_out
inc n1
mov a,n1
mov b,#24
div ab
mov a,b
jnz start_bi
cpl l3
SJMP START_BI
;********************************************** ALL SUB
timer_20ms:
mov r7,#028h
timer201:
mov r6,#0ffh
djnz r6,$
djnz r7,timer201
ret
T0:
cpl hz
mov th0,f_h
mov tl0,f_l
reti
log_in_out:
setb log
mov c,log
jc log_red
clr l2
setb l1
ret
log_red:
clr l1
setb l2
ret
read_dip:
mov a,p1
call timer_20ms
mov a,p1
anl a,#070h
swap a ;a=0,7
cjne a,hz_number,read1
ret
read1:
mov hz_number,a
mov dptr,#hz_int_data
mov b,#02
mul ab
mov b,a
movc a,@a+dptr
mov f_h,a
mov a,b
inc a
movc a,@a+dptr
mov f_l,a
;***** jb t0,t1
mov a,hz_number
cjne a,#03,read2
read3:
mov th1,f_h
mov tl1,f_l
clr tr0
setb tr1
ret
read2:
jnc read3
mov th0,f_h
mov tl0,f_l
clr tr1
setb tr0
ret
hz_int_data:
db 03ch,0b0h ;10hz
db 0ech,078h ;100Hz
db 0feh,00ch ;1000hz
db 0ceh,0ceh ;10kHz use t1
db 0e7h,0e7h ;20k
db 0f6h,0f6h ;50khz
db 0fbh,0fbh ;100kHz
db 0feh,0feh ;250khz