⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mic5402.asm

📁 CCS以及DSP/BIOS中文教程的光盘代码
💻 ASM
字号:
     .title " test vc5402'bootloader..."
     .ref _c_int00
     .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

timer_count    .set      060h
mcbsp_init     .set      061h
wave_ptr       .set      062h
is_new_data    .set      063h
new_ad         .set      064h
out_wave_ptr   .set      065h
t_ar2          .set      066h
t_ar3          .set      067h
temp           .set      068h

wave_buf       .set      0900h 
out_wave_buf   .set      01000h
N              .set      38        ; FIR taps
fir_coef_buf   .set      100h      ; FIR coef buffer
fir_data       .set      200h      ; FIR windows data buffer !

     .text
;--------------------------------------------------------------------
; interrupte vector table !
;--------------------------------------------------------------------
rs      b _c_int00
        nop
        nop
nmi     b __ret
         nop
         nop
sint17  b __ret
        nop
        nop
sint18  b __ret
        nop
        nop
sint19  b __ret
        nop
        nop
sint20  b __ret
        .word   0,0
sint21  b __ret
        .word   0,0
sint22  .word   01000h
        .word   0,0,0
sint23  .word   0ff80h
        .word   0,0,0
sint24  .word   01000h
        .word   0,0,0
sint25  .word   0ff80h
        .word   0,0,0
sint26  .word   01000h
        .word   0,0,0
sint27  .word   0ff80h
        .word   0,0,0
sint28  .word   01000h
        .word   0,0,0
sint29  .word   0ff80h
        .word   0,0,0
sint30  .word   01000h
        .word   0,0,0
int0    b __ret
        nop
        nop
int1    b __ret
        nop
        nop
int2    b __ret
        nop
        nop
tint    b timer
        nop
        nop
brint0  b receive
        nop
        nop
bxint0  b transmit
        nop
        nop
trint    b  __ret
        nop
        nop
txint   b __ret
        nop
        nop
int3    b __ret
        nop
        nop
hpint   b __ret
        nop
        nop
q26     .word   0ff80h
        .word   0,0,0
q27     .word   01000h
        .word   0,0,0
q28     .word   0ff80h
        .word   0,0,0
q29     .word   01000h
        .word   0,0,0
q30     .word   0ff80h
        .word   0,0,0
q31     .word   01000h
        .word   0,0,0
;--------------------------------------------------------------------------
; end of interrupte vector table !
;-------------------------------------------------------------------------
_c_int00:
     stm  #2020h,pmst    ; vector table start: 0x2000
     ssbx intm           ; close all int ! (ssbx intm)
     ssbx sxm            ; extend sign !
     ssbx frct           ; faction multiply
     stm  #10h,26h       ; stop TIMER0 !
     stm  #10h,36h       ; stop TIMER1 !
     stm  #0ffh,sp       ; sp= 0x0ff
     ld   #0,dp          ; dp=0 
     stm  #0ffffh,ifr    ; clear all int !
     stm  #20h,imr       ; bit5->BXINT0, bit4->BRINT0, enable BXINT0
     stm  #02492h,swwsr  ; all 2 waits !
     stm  #0,swcr
;/*------------------------------------------------------------------------
;  The following codes switch to 100MHz clock !
;-------------------------------------------------------------------------*/
     stm  #0,58h
wait_pll:
     ldm  58h,a
     and  #1,a
     bc   wait_pll,aneq
     stm  #87ffh,58h      ; switch pll*10 -> 100M clk

     rpt  #100
     nop
;***********************************************************************
; initalize RAM, Variable....
;***********************************************************************
     stm  #wave_buf,ar6
     stm  #1,ar0
     rpt  #24
     mvpd wave_data,*ar6+0         ; move wave data to wave_buf -> 0x6000h
     stm  #wave_buf,wave_ptr       ; save wave buffer'ptr
     stm  #out_wave_buf,out_wave_ptr   ; save out wave buffer'ptr, because use
                                   ; circular address, so when save out_wave
                                   ; date,must ++ !

     stm  #fir_coef_buf,ar6
     rpt  #N-1
     mvpd fir_coef,*ar6+           ; move fir coef to fir_coef_buf(in data mem)
     stm  #fir_coef_buf,t_ar2      ;
     stm  #fir_data,t_ar3

     stm  #0aa55h,mcbsp_init  ; when mcbsp_init==0xaa55, transmit for init ac01
     stm  #5,timer_count      ; init variable timer_count !
     stm  #0,is_new_data      ; if is_new_data ==1 , has new AD data by slave ac01 !
     stm  #1000h,ar0
     stm  #1800h,ar5
     stm  #400h,bk
     ld   *ar0,t
     ld   #0,b
;******************************************************************
; 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  #0ffffh
     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
     stm  #2001h,39h     ; start MCbsp0 receive !
     stm  #10h,imr       ; bit5->BXINT0, bit4->BRINT0, disable BXINT0
;******************************************************************
; The following codes are used to initalize TIMER !
;******************************************************************
     stm  #10h,tcr       ; stop TIMER !
     stm  #0ffffh,prd    ;
     stm  #0fh,tcr       ; TIMER start, each about 100HZ ....
     orm  #8,imr         ; enable TIMER INT !

again:
     bitf is_new_data,#1 ; test is_new_data == 1 ?
     cc   fir,tc         ; ==1, then call fir ! new AD data in new_ad(0x64)
     b    again

;*********************************************************************
;  The following codes are serived for McBSP0' transmit !
;*********************************************************************
transmit:
     pshm st1
     pshm st0
     pshm bk
     pshm ar7
     pshm ah
     pshm al

     cmpm mcbsp_init,#0aa55h
     bc   init,tc
     stm  #25,bk              ; each AC01 has 25 dots to D/A !
     mvdm #wave_ptr,ar7       ; restore wave buffer ptr !
     nop
     ld   *ar7+%,a
     nop
     stlm a,dxr10        ; send wave data ! Master AC01 make source wave,
                         ; Slave AC01 make filter result wave !
     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 codes are serived for McBSP0' receive ! use AR5,BK!
;*********************************************************************
receive:
     pshm st1
     pshm st0

     ld   #0,dp
     mvkd drr10,*ar5     ; save AD data   
     mvdk *ar5,dxr10     ; send A/D data to D/A
     pshd *ar5+%         ; save AD data in AD_buffer(0x1800-0x1c00)
     popd new_ad
     stm  #1,is_new_data ; has new AD data
   

     popm st0
     popm st1
     rete
;********************************************************************
;  The following codes are serived for vc5402' TIMER !
;*********************************************************************
timer:
     pshm ah
     pshm al

     ldm  timer_count,a
     sub  #1,a
     bc   not_show_led,aneq   ; if a != 0 ,jump !
     bitf st1,#2000h          ; test XF?
     bc   show_led,tc
     ssbx xf                  ; set xf=1
     b    show_con
show_led:
     rsbx xf                  ; set xf=0
show_con:
     ld   #5,a                ; 
not_show_led:
     stlm a,timer_count
     popm al
     popm ah

     rete
;************************************************************************
; The following codes is used to FIR, new AD DATA in new_ad(0x64)
; FIR buffer coff-> 0x100(ar2), FIR window buffer -> 0x200(ar3)
;************************************************************************
fir:
     pshm st1
     pshm st0
     pshm bk
     pshm ar7
     pshm ah
     pshm al
     pshm ar0
     pshm ar2
     pshm ar3

     mvdm #t_ar2,ar2          ; restore ar2
     mvdm #t_ar3,ar3          ; restore ar3
     ld   new_ad,-2,a         ; new AD data -> a, remove two LSBs

     stm  #1,ar0
     stm  #N,bk                              ; set circular addressing size
     stl  a,*ar3+%
     rptz a,#(N-1)                           ; 0 -> a, then repeat 34 times
     mac  *ar2+0%,*ar3+0%,a                  ; done FIR filter, result in ah
     mvmd ar3,#t_ar3          ; save ar3
     mvmd ar2,#t_ar2          ; save ar2

     stm  #1,ar0
     stm  #100h,bk              ; each AC01 has 25 dots to D/A !
     mvdm #out_wave_ptr,ar7   ; restore wave buffer ptr !
     sth  a,-2,temp           ; save FIR result in temp
     ld   temp,2,a            ; shift 2 bit for AC01 D/A !
     stl  a,*ar7+0%           ; save FIR result to wave buffer !
     stl  a,temp 

;     ld #0,dp
;     stl  a,dxr10 
     
     mvmd ar7,#out_wave_ptr   ; save wave buffer ptr !
     stm  #0,is_new_data      ; new AD data has been processed !
       
     ld  #0,dp
     cmpm out_wave_ptr, 1000h
     bc  con_fir,ntc
ccs_show:
     nop                      ; if out_wave_ptr == 0xc00, 
     nop                  	  ; may show out_wave in CCS !!! show 128 dots !       
                              ; input buffer -> 0x1800   
                              ; output buffer -> 0x1000 (show from 0x1020)    
con_fir:       
     popm ar3
     popm ar2
     popm ar0
     popm al
     popm ah
     popm ar7
     popm bk
     popm st0
     popm st1
     ret

;************************************************************************
; 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     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
;************************************************************************
;    Filter Type         Lowpass
;    Filter Length       38
;    Sampling Frequency  25.00000000
;    Upper Band Edge        1.20000005
;    Lower Band Edge        2.79999995
;**********************************************************************
fir_coef:
     .word      34        ;C037
     .word      235       ;C036
     .word      500       ;C035
     .word      735       ;C034
     .word      808       ;C033
     .word      587       ;C032
     .word      0         ;C031
     .word      -914      ;C030
     .word      -1972          ;C029
     .word      -2854          ;C028
     .word      -3163          ;C027
     .word      -2518          ;C026
     .word      -662      ;C025
     .word      2432      ;C024
     .word      6516      ;C023
     .word      11078          ;C022
     .word      15431          ;C021
     .word      18849          ;C020
     .word      20728          ;C019
     .word      20728          ;C018
     .word      18849          ;C017
     .word      15431          ;C016
     .word      11078          ;C015
     .word      6516      ;C014
     .word      2432      ;C013
     .word      -662      ;C012
     .word      -2518          ;C011
     .word      -3163          ;C010
     .word      -2854          ;C009
     .word      -1972          ;C008
     .word      -914      ;C007
     .word      0         ;C006
     .word      587       ;C005
     .word      808       ;C004
     .word      735       ;C003
     .word      500       ;C002
     .word      235       ;C001
     .word      34        ;C000

     .end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -