📄 dtmf.asm
字号:
.title " send sound from AC01 ..."
.global _start_ac01,_iir_to_dtmf,_ac01_init,_In_Buffer
.global _A1,_A2,_B,_IIR_y1n_1,_IIR_y1n_2,_IIR_y2n_1,_IIR_y2n_2
.mmregs
.ref _transmit,xint0
.bss _In_Buffer,256 ; save input of DTMF
gpiocr .set 3ch
gpiosr .set 3dh
dxr10 .set 23h
drr10 .set 21h
spsa0 .set 38h
spcr10 .set 39h
spcr20 .set 39h
xcr10 .set 39h
pcr0 .set 39h
dxr11 .set 43h
spsa1 .set 48h
spcr11 .set 49h
spcr21 .set 49h
xcr11 .set 49h
pcr1 .set 49h
srgr1 .set 49h
srgr2 .set 49h
swcr .set 2bh
wave_data_length .set 40
timer_count .set 067h
mcbsp_init .set 068h
wave_ptr .set 069h
temp .set 06ch
.text
_start_ac01:
pshm st0
pshm st1
pshm ar0
pshm ar6
pshm ar7
pshm bk
ssbx intm ; close all int ! (ssbx intm)
rsbx cpl ; cpl=0
ld #0,dp ; dp=0
ldm imr,a
nop
nop
stlm a,temp ; save imr reg !
stm #20h,imr ; bit5->BXINT0, bit4->BRINT0, enable BXINT0
;******************************************************************
; The following codes are used to initalize McBSP0 !
;******************************************************************
stm #0,spsa0 ; choose SPCR10
stm #2000h,spcr10 ; receive sign_extend in DRR
stm #1,spsa0 ; choose SPCR20
stm #0c0h,spcr20 ; fs -> int !
stm #2,spsa0 ; choose RCR10
stm #40h,39h
stm #3,spsa0 ; choose RCR20
stm #0,39h
stm #4,spsa0 ; choose XCR10
stm #40h,xcr10
stm #5,spsa0 ; choose XCR20
stm #0,39h
stm #0eh,spsa0 ; choose PCR0
stm #0dh,pcr0 ; fs is low active, rise edge of clkx, falling edge
; of clkr
stm #7h,spsa0
stm #8000h,39h
rpt #0ffh
nop
stm #00h,dxr10
ldm 22h,a
stm #1,38h
stm #0c1h,39h ; start McBSP0 send !
ld #603h,a
rsbx intm ; enable all int !
;----------------------------------------------------------------------
; The following codes are initalized AC01, ALL AC01 setup same !
;----------------------------------------------------------------------
idle 1
idle 1
idle 1
idle 1 ; reset two AC01 by software !
ld #600h,a
idle 1 ; wait for int .....
ld #3,a
idle 1 ; send #3
ld #0011eh,a ; fs=10M/2/A/B= 8.333k
; flp=10M/2/40/A= 4.16k
; fhp=fs/200= 125Hz (not use !)
; A=30(0x1e),B=20(0x14)
idle 1 ; send 1th regs -> 1eh
ld #3,a
idle 1 ; send #3
ld #00214h,a
idle 1 ; send 2th regs -> 14h
ld #3,a
idle 1 ; send #3
ld #00300h,a
idle 1 ; send 3th regs -> 00h
ld #3,a
idle 1 ; send #3
ld #00405h,a
idle 1 ; send 4th regs -> 05h (AD & DA 0 dB)
ld #3,a
idle 1 ; send #3
ld #00505h,a
idle 1 ; send 5th regs -> 05h (highpass filter disable)
ld #3,a
idle 1 ; send #3
ld #00600h,a
idle 1 ; send 6th regs -> 00h
ld #3,a
idle 1 ; send #3
ld #00700h,a
idle 1 ; send 7th regs -> 0
ld #3,a
idle 1 ; send #3
ld #800h,a
idle 1 ; send 8th regs -> 0
ld #0h,a
stm #0,38h
stm #2001h,39h ; start MCbsp0 receive !
ssbx intm ; close all int
ldm temp,a ; restore imr
or #30h,a ; enable xint0,rint0
stlm a,imr
popm bk
popm ar7
popm ar6
popm ar0
popm st1
popm st0
rete ; enable all int !
; calculate to new SIN by use IIR
_iir_to_dtmf:
pshm st1
pshm st0
pshm bh
pshm bl
ssbx frct
ld *(_A1),T ; A -> T
mpy *(_IIR_y1n_1),a ; A*y[n-1]
ld *(_B),T
mac *(_IIR_y1n_2),a ; A*y[n-1]+B*y[n-2]
mvkd #_IIR_y1n_1,*(_IIR_y1n_2) ; y[n-1] -> y[n-2]
sth a,1,*(_IIR_y1n_1) ; y[n] -> y[n-1]
; make one freqency !
ld *(_A2),T
mpy *(_IIR_y2n_1),b
ld *(_B),T
mac *(_IIR_y2n_2),b ; make two freqency !
mvkd #_IIR_y2n_1,*(_IIR_y2n_2)
sth b,1,*(_IIR_y2n_1)
add a,b ; add two freqency !
sfta b,-1,b
and #0fffch,16,b,b ; make low 2 bits of bh to 0
sth b,*(dxr10) ; send to McBSP0 to ...
popm bl
popm bh
popm st0
popm st1
ret
;------------------------------------------------------
;--when init. AC01, use this inpterrupt service, if done,
; must change to _transmit program !
;-----------------------------------------------------
_ac01_init:
stlm a,dxr10
bitf dxr10,#800h ; if setup last reg of AC01, set mcbsp_init=0 !
bc send_end,ntc ; not equal ,jump !
st #_transmit,*(xint0+1) ; change xint0's int service !
send_end:
rete
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -