一款摩托车防盗器资料 警报发声模块原代码
注:警报音频率为1.8K到3.5K之间,具体请查资料
OSCILLATION:R/C =晶振 CLOCK = 2
Frequency =4MHZ
;=================================================================*/
Fre_COUNT EQU 0X37 ;'声音频率变化计数器,从1.8~3.55KHZ
Fre_Repeat EQU 0x38 ;'同一频率的重复次数
SOUND_TEMP EQU 0X39
;'Replace program variable value and debug is more than easy.
S_Loop EQU 67 ;'MAX-MIN
S_MAX EQU 138
S_MIN EQU 71
S_Repeat EQU 4
;开始0.2秒发音
SOUND200ms:
SOUND_LH: ;1.8~3.55
MOV A,@S_Loop ;66=134-68
MOV Fre_COUNT,A
SOUND_LH_LP:
MOV A,@S_Repeat ;
MOV Fre_Repeat,A
MOV A,Fre_COUNT
ADD A,@S_MIN ;
repeat0_lp BS PORT6,BUZ
CALL SOUNDDELAY0
BC PORT6,BUZ
CALL SOUNDDELAY0
DJZ Fre_Repeat
JMP repeat0_lp
DJZ Fre_COUNT
JMP SOUND_LH_LP
SOUND_HL: ;3.55~1.8
MOV A,@S_Loop ;66=134-68
MOV Fre_COUNT,A
SOUND_HL_LP:
MOV A,@S_Repeat ;
MOV Fre_Repeat,A
MOV A,Fre_COUNT
SUB A,@S_MAX ;
repeat1_lp BS PORT6,BUZ
CALL SOUNDDELAY0
BC PORT6,BUZ
CALL SOUNDDELAY0
DJZ Fre_Repeat
JMP repeat1_lp
DJZ Fre_COUNT
JMP SOUND_HL_LP
SOUND_END: ;
RET
;**********************************************************
Sound2s: ;2S内短鸣两声
WARNING1:
CALL Sound200ms
CALL Delay800ms
CALL Sound200ms
CALL Delay800ms
RET
Delay800ms:
CLR TIME1 ;'get ready for 0.8 second delay.
Sound_delay MOV A,@196 ;'delay 0.8 second
SUB A,TIME1
JBS R3,0
JMP Sound_delay
RET
;************************************************
Sound15s: ;连续报警15S
WARNING2:
MOV A,@73
MOV SOUND_TEMP,A
Sound1s_lp CALL Sound200ms
JBC PORT6,SDT ;'SDT上电立即中断报警
RET
DJZ SOUND_TEMP
JMP Sound1s_lp
RET
;============================
SOUNDDELAY1 EQU 0X3A
sounddelay:
mov a,@18 ;
sounddelay0 mov sounddelay1,a ;=(A*9)+3
wdtc
sounddelayus_1:
nop
nop
nop
nop
nop
nop
djz sounddelay1
jmp sounddelayus_1
ret