📄 dtmf.s03
字号:
; 6
db F770 ;fLOW = 770
db F1477 ;fHIGH = 1477
db 62
db 0
; 7
db F852 ;fLOW = 852
db F1209 ;fHIGH = 1209
db 68
db 0
; 8
db F852 ;fLOW = 852 (853)
db F1336 ;fHIGH = 1336 (1340)
db 68
db 0
; 9
db F852 ;fLOW = 852 (853)
db F1477 ;fHIGH = 1477 (1477)
db 68
db 0
; A
db F697 ;fLOW = 697 (698)
db F1633 ;fHIGH = 1633 (1622)
db 56
db 0
; B
db F770 ;fLOW = 770 (768)
db F1633 ;fHIGH = 1633 (1622)
db 62
db 0
; C
db F852 ;fLOW = 852 (853)
db F1633 ;fHIGH = 1633 (1622)
db 68
db 0
; D
db F941 ;fLOW = 941 (944)
db F1633 ;fHIGH = 1633 (1622)
db 76
db 0
; *
db F941 ;fLOW = 941 (944)
db F1209 ;fHIGH = 1209 (1213)
db 76
db 0
; #
db F941 ;fLOW = 941 (944)
db F1477 ;fHIGH = 1477 (1477)
db 76
db 0
org 04000h
test:
orl P1,#00001001b ;1/2 scale
mov SP,#050H ;init stack
setb EA ;enable interrupts
mov a,#80h ;do dial-tone
call LOAD_DTMF ;set it up
orl TCON,#01010000b ;turn on the timers
mov dptr,#200 ;wait 2 seconds
call TONE_WAIT
anl TCON,#10101111b ;turn off the timers
; the following is non-optimal but easy to understand
; This will output the Amaze BBS number, after you get things
; working audio couple the DTMF into your phone to dial SIGNETICS
; AMAZE. It does work. I've done it!!
mov a,#1
call SEND_DTMF
mov a,#8
call SEND_DTMF
mov a,#0
call SEND_DTMF
mov a,#0
call SEND_DTMF
mov a,#4
call SEND_DTMF
mov a,#5
call SEND_DTMF
mov a,#1
call SEND_DTMF
mov a,#6
call SEND_DTMF
mov a,#6
call SEND_DTMF
mov a,#4
call SEND_DTMF
mov a,#4
call SEND_DTMF
; try busy
busyl:
mov dptr,#200 ;quiet for 2 sec's.
call QUIET_WAIT
mov r3,#10
busyll:
mov a,#82h ;do busy
call LOAD_DTMF ;set it up
mov r7,CNT_10mS ;get 10mS count value
orl TCON,#01010000b ;turn on the timers
mov dptr,#50 ;wait 500 mS
call TONE_WAIT
anl TCON,#10101111b ;timers off
anl IE,#11110101b ;timer intr's off
mov dptr,#50
call QUIET_WAIT
djnz r3,busyll
mov dptr,#200
call QUIET_WAIT
ringl:
mov dptr,#100 ;silent line for 1 second
call QUIET_WAIT
mov r3,#7 ;do 7 busy cycles
ringll:
mov a,#81h ;do ring-back
call LOAD_DTMF ;set it up
mov r7,CNT_10mS ;get 10mS count value
orl TCON,#01010000b ;turn on the timers
mov dptr,#200 ;wait 2 seconds
call TONE_WAIT
anl TCON,#10101111b ;timers off
anl IE,#11110101b ;timer intr's off
mov dptr,#400 ;4 seconds off
call QUIET_WAIT
djnz r3,ringll ;send busy cycle till r3=0
mov dptr,#200 ;2 second off
call QUIET_WAIT
ljmp test
;===============
; send a dtmf tone for the char in <ACC>
SEND_DTMF:
call LOAD_DTMF ;init timers for this tone
TONE_OUT:
mov r7,CNT_10mS ;get 10mS count value
orl TCON,#01010000b ;turn on the timers
mov dptr,#10 ;wait 100 mS
call TONE_WAIT ;send tone while waiting
anl TCON,#10101111b ;timers off
anl IE,#11110101b ;timer intr's off
mov a,P1 ;fetch funny DAC port
anl a,#0f0h ;preserve non-DAC bits
orl a,#00001001b ;set DAC to mid scale
mov P1,a ;ship it
mov dptr,#7 ;wait 70 mS
call QUIET_WAIT ;no tone out
ret
;===============
; The following waits for the number of
; 10 mS tics contained in dptr
; ENTRY: dptr = (time/10mS)
QUIET_WAIT:
mov a,P1 ;fetch funny DAC port
anl a,#0f0h ;preserve non-DAC bits
orl a,#00001001b ;set DAC to mid scale
mov P1,a ;ship it
setb INT_FLAGS.1 ;fag tictoc intr.
anl IE,#11110101b ;timer intr's off
anl TCON,#10101111b ;timers off
mov TMOD,#022h ;8 bit auto-reload
mov TL0,#LOW(-200)
mov TH0,#LOW(-200) ;app. 217 uS
setb ET0 ;enable T0 intr
setb TR0 ;T0 on
mov r7,#46 ;46 * 217 uS = 9.98 mS
Q_loop1:
mov CNT_10mS,r7 ;set-up count
Q_loop2:
mov a,CNT_10mS ;get flag
jnz Q_loop2 ;go till 10 mS done?
call dec_dptr ;1 less 10 mS tick
mov a,dpl ;do 16 bit
orl a,dph ;compare = 0
jnz Q_loop1 ;go till no ticks left
anl IE,#11110101b ;timer intr's off
anl TCON,#10101111b ;timers off
clr INT_FLAGS.1 ;release tictoc intr.
ret ;done
;====================
TONE_WAIT:
mov a,CNT_10mS ;wait for 10 mS tick
jnz TONE_WAIT ;go till we have it
mov CNT_10mS,r7 ;re-init tick time
call dec_dptr ;1 tick is gone
mov a,dpl
orl a,dph ;dptr = 0 ?
jnz TONE_WAIT ;go till all ticks gone
ret
;=====================
dec_dptr:
xch a,dpl
jnz dec_dptr2
dec dph
dec_dptr2:
dec a
xch a,dpl
ret
;=====================
; The following is the tick-tock interrupt
; routine. No waveforms are generated only
; CNT_10mS is decremented for use as a timer.
TICTOC0:
dec CNT_10mS
reti
;=====================
; the following are the timer intr routines
; various functions are performed based on the
; state of the INT_FLAGS
T0INT:
push acc
jb INT_FLAGS.0,T0INTD ;auto-reoad if dtmf
mov a,TL0
add a,SIGNAL_HIGH+1 ;adjust for intr latency
mov TL0,a
mov a,TH0
addc a,SIGNAL_HIGH
mov TH0,a
T0INTD:
inc fHIGH
sjmp Tintmrg
T1INT:
push acc
jb INT_FLAGS.0,T1INTD ;skip next if dtmf
mov a,TL1
add a,SIGNAL_LOW+1
mov TL1,a
mov a,TH1
addc a,SIGNAL_LOW
mov TH1,a
T1INTD:
inc fLOW
dec CNT_10mS ;hit 10 mS timer
Tintmrg :
push Reg0
mov a,fLOW
jnb acc.2,$+5
xrl a,#3
anl a,#3
mov r0,a
mov a,fHIGH
jnb acc.2,$+5
xrl a,#3
anl a,#3
rl a
rl a
orl a,r0
mov P1,a
pop Reg0
pop acc
reti
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -