📄 hpass.asm
字号:
BSP .set 0 ;当前使用McBsp1
;McBsp 内存映射寄存器
SPSA0 .set 038h
SPSD0 .set 039h
DRR10 .set 021h
DRR20 .set 020h
DXR10 .set 023h
DXR20 .set 022h
SPSA1 .set 048h
SPSD1 .set 049h
DRR11 .set 041h
DRR21 .set 040h
DXR11 .set 043h
DXR21 .set 042h
SPSA2 .set 034h
SPSD2 .set 035h
DRR12 .set 031h
DRR22 .set 030h
DXR12 .set 033h
DXR22 .set 032h
;McBsp Subaddressed Registers
SPCR1 .set 00h
SPCR2 .set 01h
RCR1 .set 02h
RCR2 .set 03h
XCR1 .set 04h
XCR2 .set 05h
SRGR1 .set 06h
SRGR2 .set 07h
MCR1 .set 08h
MCR2 .set 09h
RCERA .set 0ah
RCERB .set 0bh
XCERA .set 0ch
XCERB .set 0dh
PCR .set 0eh
.if BSP = 0
SPSA .set SPSA0
SPSD .set SPSD0
RDRR .set DRR10
RDXR .set DXR10
IMASK .set 0010h
.endif
.if BSP = 1
SPSA .set SPSA1
SPSD .set SPSD1
RDRR .set DRR11
RDXR .set DXR11
IMASK .set 0400h
.endif
;fin_flag .set 64h
.asg AR0,FIR_INDEX_P
.asg AR4,FIR_DATA_P
.asg AR5,FIR_COFF_P
DELAY .macro sec_tenth ;延时 sec_tenth/10 秒
STM sec_tenth-1,AR5
loop1? STM #09h,AR6
loop0? STM #19999,AR7
BANZ $,*AR7-
BANZ loop0?,*AR6-
BANZ loop1?,*AR5-
.endm
WR_SUB_REG .macro val,addr ;写McBsp控制寄存器
stm addr,SPSA
nop
stm val,SPSD
nop
.endm
RD_SUB_REG .macro addr,acc ;读McBsp控制寄存器
stm #:addr:,SPSA
nop
ldm SPSD,acc
nop
nop
nop
.endm
WAITTRX .macro ;等待串口中断
WAITR?
RD_SUB_REG SPCR1,A
and #1<<1, A
bc WAITR?, AEQ
.endm
PROGREG .macro progword ;与AD50二次通讯
stm #01h,RDXR
WAITTRX
stm #:progword:,RDXR
WAITTRX
.endm
wait .macro
STM #0008h, AR2
RPT *AR2
NOP
.endm
.mmregs
.global _c_int00
.sect ".vectors"
RESET b _c_int00
nop
nop
.space 19*4*16
BRINT0 b recv
nop
nop
BXINT0 b trans
nop
nop
.space 10*4*16
K_FIR_BFFR .set 80
coff_fir_table .sect "coff_fir"
h0 .word 0
h1 .word -22
h2 .word 4
h3 .word 25
h4 .word -9
h5 .word -32
h6 .word 18
h7 .word 40
h8 .word -32
h9 .word -49
h10 .word 53
h11 .word 56
h12 .word -81
h13 .word -60
h14 .word 118
h15 .word 58
h16 .word -164
h17 .word -46
h18 .word 219
h19 .word 20
h20 .word -218
h21 .word 25
h22 .word 350
h23 .word -93
h24 .word -423
h25 .word 190
h26 .word 497
h27 .word -327
h28 .word -569
h29 .word 516
h30 .word 638
h31 .word -784
h32 .word -699
h33 .word 1184
h34 .word 749
h35 .word -1858
h36 .word -787
h37 .word 3335
h38 .word 811
h39 .word -10376
h40 .word 15554
h41 .word -10376
h42 .word 811
h43 .word 3335
h44 .word -787
h45 .word -1858
h46 .word 749
h47 .word 1184
h48 .word 699
h49 .word 638
h50 .word 516
h51 .word -569
h52 .word -327
h53 .word 497
h54 .word 190
h55 .word -423
h56 .word -93
h57 .word 350
h58 .word 25
h59 .word -281
h60 .word 20
h61 .word 219
h62 .word -46
h63 .word -164
h64 .word 58
h65 .word 118
h66 .word -60
h67 .word -81
h68 .word 56
h69 .word 53
h70 .word -49
h71 .word -32
h72 .word 40
h73 .word 18
h74 .word -32
h75 .word -9
h76 .word 25
h77 .word 4
h78 .word -22
h79 .word 0
d_data_buffer .usect "fir_bfr",200
.text
_c_int00
ld #0h,DP
stm #7ffh,SP
ssbx INTM
ssbx SXM
st #2491h,SWWSR
st #0ffe0h,PMST
ST #0h,CLKMD
tst: BITF CLKMD,#1h
BC tst,TC
ST #0f007h,CLKMD
BITF CLKMD,#1h
RPT #0FFh
NOP
stm #4000h,ar6
stm #4500h,ar3
stm #1000h,ar7
ld #0,a
wer stl a,*ar6+
banz wer,*ar7-
stm #4000h,ar6
stm #999,ar7
stm #5000h,ar1
fir_init
stm #1,AR0 ;step=1
stm #coff_fir_table,FIR_COFF_P ;fir_data_p=ar4
stm #d_data_buffer,FIR_DATA_P ;fir_data_p=ar5
rptz A,#K_FIR_BFFR ;fir_data_p=0
stl A,*FIR_DATA_P
stm #(d_data_buffer+K_FIR_BFFR-1),FIR_DATA_P ;ar4=ar4+79
stm #K_FIR_BFFR,BK ;bk=80
mcbsp_init ;初始化McBsp串口
rsbx CPL
nop ; cpl latency
nop ; cpl latency
nop ; cpl latency
ld #0,DP
ssbx INTM
ssbx SXM
WR_SUB_REG #0000H,SPCR1
WR_SUB_REG #0200H,SPCR2
WR_SUB_REG #000CH,PCR
WR_SUB_REG #0000H,SPCR1
WR_SUB_REG #0000H,SPCR2
WR_SUB_REG #0040H,RCR1 ;16 BITs
WR_SUB_REG #0004H,RCR2 ;Ignore FS after the first
WR_SUB_REG #0040H,XCR1 ;16 BITs
WR_SUB_REG #0004H,XCR2 ;Ignore FS after the first
ld 100,A
wait
andm #0ff3fh, 54h ;set interrupts to come from serial ports not DMA
;by clearing bits 6 and 7 in DMPREC
stm #0,RDXR
WR_SUB_REG #0001H,SPCR1 ;启动McBsp串口
WR_SUB_REG #0201H,SPCR2
ld 100,A
wait
aic_init
stm #0h,IMR
orm #30h,IMR
stm #0ffffh,IFR
PROGREG 0301h
PROGREG 0410h
ld RDRR,A
ld RDRR,A
stlm A,RDXR
stlm A,RDXR
rsbx INTM
nop
nop
nop
js nop
nop
nop
b js
recv ldm RDRR,A ;ADC采样数据滤波存放到A中
ld a,b ;ADC采样数据不滤波存放到B中
stl A,*FIR_DATA_P+0% ; 代替原来的数据
rptz A,(K_FIR_BFFR-1) ; 80阶
mac *FIR_DATA_P+0%,*FIR_COFF_P+0%,A ;
andm #0fffeh,ah
sth A,RDXR ;portw out
banz rrr,*ar7- ;反复1000h次
stm #1000,ar7
stm #4000h,ar6
stm #4500h,ar3
rsbx XF
rete
rrr stl b,*ar3+ ;没有滤波的放在AR3里4500H
stl a,*ar6+ ; 滤了的数据放在AR6里4000H
rete
trans rsbx XF
rete
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -