📄 speak.asm
字号:
.title " send sound from AC01 ..."
.global _speak,transmit
.mmregs
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
temp1 .set 06ah
temp2 .set 06bh
temp .set 06ch
.bss wave_buf,64,1,64 ; alloc 64 words space !
.text
_speak:
frame -1
nop
stlm a,temp1 ; save 1st para from main function
mvdk 2h,temp2 ; save 2nd para from main function
frame +1
nop
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
;***********************************************************************
; initalize RAM, Variable....
;***********************************************************************
stm #wave_buf,ar6
stm #1,ar0
rpt #wave_data_length-1
mvpd wave_data,*ar6+0 ; move wave data to wave_buf -> 0x6000h
stm #wave_buf,wave_ptr ; save wave buffer'ptr
stm #0aa55h,mcbsp_init ; when mcbsp_init==0xaa55, transmit for init ac01
mvkd temp1,timer_count ; init variable timer_count !
; when timer_count=0, close sound auto !
;******************************************************************
; 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 #00105h,a ; fs=10M/2/A/B= 25k
; flp=10M/2/40/A= 25k (all pass)
; fhp=fs/200= 125Hz (not use !)
; A=05,B=40(0x28)
idle 1 ; send 1th regs -> 05h
ld #3,a
idle 1 ; send #3
ld #00228h,a
idle 1 ; send 2th regs -> 28h
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
ssbx intm ; close all int
ldm temp,a ; restore imr
or #20h,a ; enable xint0
stlm a,imr
rsbx intm ; enbale all int
again:
cmpm timer_count,#0 ; test timer_counter == 0 ?
bc again,ntc ; !=0, then waiting
popm bk
popm ar7
popm ar6
popm ar0
popm st1
popm st0
ret
;*********************************************************************
; The following codes are serived for McBSP0' transmit !
;*********************************************************************
transmit:
pshm st1
pshm st0
pshm bk
pshm ar7
pshm ah
pshm al
rsbx cpl ; cpl=0
ld #0,dp
nop
nop
cmpm mcbsp_init,#0aa55h
bc init,tc
stm #wave_data_length,bk ; each sound has xx dots to D/A !
mvdm #wave_ptr,ar7 ; restore wave buffer ptr !
nop
ld *ar7+%,a
nop
stlm a,dxr10 ; send wave data !
ld timer_count,a ; timer_count --> a
sub #1,a,a
stl a,timer_count ; save new(timer_count--)
bc next_sound,aneq ; if timer_count !=0, continue
andm 0ffdfh,IMR ; disable xint0 !
next_sound:
bd wave_make_end
mvmd ar7,#wave_ptr ; save wave buffer ptr !
init:
stlm a,dxr10
bitf dxr10,#800h ; if setup last reg of AC01, set mcbsp_init=0 !
bc wave_make_end,ntc ; not equal ,jump !
stm #0,mcbsp_init ; when mcbsp==0 or 1, transmit for make wave !
wave_make_end:
popm al
popm ah
popm ar7
popm bk
popm st0
popm st1
__ret:
rete
;************************************************************************
; The following data is used by make wave ! when using, must copy to
; wave buffer -> 0x6000
;************************************************************************
wave_data: ; freq about 1k Hz
.word 03ffch ; +2 volt
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 03ffch
.word 0c000h ; -2 volt
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h ; -2 volt
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.word 0c000h
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -