📄 ex10.asm
字号:
************************************************
* FileName: ex10.asm *
* Description: 滤波器实验lowpass 0—1000Hz *
* Copyright(C) SanZhi Electronic, Author LY *
************************************************
.title "ex10"
BSP .set 0 ;当前使用McBsp0, BSP,所用McBsp口标志
; BSP=0时,使用McBsp0,BSP=1时,使用McBsp1, 见后面条件编译.
; 本处给值0,使用McBsp0。
;McBsp 所用的内存映射寄存器的地址,它们是固定的,可查表。
;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 ;
WR_SUB_REG .macro val,addr ;写McBsp控制寄存器
; 向所指定的McBsp控制寄存器写入内容val。
stm addr,SPSA ;; 给出子地址寄存器SPSA地址
nop
stm val,SPSD ;; 向所指定的McBsp控制寄存器写入内容val。
nop
.endm
RD_SUB_REG .macro addr,acc ;读McBsp控制寄存器
; 将所指定的McBsp控制寄存器的内容读到acc中。
stm #:addr:,SPSA; 给出子地址寄存器SPSA地址
nop
ldm SPSD,acc ;将该串口的控制寄存器内容读到ACC
nop
nop
nop
.endm
WAITTRX .macro ;等待串口中断
WAITR?
RD_SUB_REG SPCR1,A ;将串口控制寄存器1内容读到A中。
and #1<<1, A ;与1与,左移一位后再送回到A
bc WAITR?, AEQ ; A=0时,转向WAITR?
.endm
PROGREG .macro progword ;与AD50二次通讯
;把宏参数progword送到发送寄存器中
stm #01h,RDXR ; 将#01H写到RDXR,既发送寄存器中
WAITTRX ; 调用宏指令,等待串口控制寄存器内容第0位变成1
stm #:progword:,RDXR ;把宏参数progword送到发送寄存器中
WAITTRX ;
.endm
wait .macro ;等待一段时间的宏指令。很短时间。
STM #0008h, AR2
RPT *AR2
NOP
.endm
.mmregs; 引入.MMREG存储器定义文件
.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 -157
h2 .word -261
h3 .word -268
h4 .word -170
h5 .word 0
h6 .word 180
h7 .word 301
h8 .word 310
h9 .word 198
h10 .word 0
h11 .word -211
h12 .word -354
h13 .word -367
h14 .word -236
h15 .word 0
h16 .word 255
h17 .word 431
h18 .word 451
h19 .word 292
h20 .word 0
h21 .word -323
h22 .word -551
h23 .word -584
h24 .word -383
h25 .word 0
h26 .word 438
h27 .word 763
h28 .word 827
h29 .word 557
h30 .word 0
h31 .word -681
h32 .word -1240
h33 .word -1417
h34 .word -1022
h35 .word 0
h36 .word 1533
h37 .word 3307
h38 .word 4960
h39 .word 6131
h40 .word 6131
h41 .word 4960
h42 .word 3307
h43 .word 1533
h44 .word 0
h45 .word -1022
h46 .word -1417
h47 .word -1240
h48 .word -681
h49 .word 0
h50 .word 557
h51 .word 827
h52 .word 763
h53 .word 438
h54 .word 0
h55 .word -383
h56 .word -584
h57 .word -551
h58 .word -323
h59 .word 0
h60 .word 292
h61 .word 451
h62 .word 431
h63 .word 255
h64 .word 0
h65 .word -236
h66 .word -367
h67 .word -354
h68 .word -211
h69 .word 0
h70 .word 198
h71 .word 310
h72 .word 301
h73 .word 180
h74 .word 0
h75 .word -170
h76 .word -268
h77 .word -261
h78 .word -157
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 #1087h,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 ;
stm #coff_fir_table,FIR_COFF_P ;
stm #d_data_buffer,FIR_DATA_P ;
rptz A,#K_FIR_BFFR ;
stl A,*FIR_DATA_P ;
stm #(d_data_buffer+K_FIR_BFFR-1),FIR_DATA_P ;
;
stm #K_FIR_BFFR,BK ;
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) ;
mac *FIR_DATA_P+0%,*FIR_COFF_P+0%,A ;
;
;
andm #0fffeh,ah ;
;stl A,RDXR
sth A,RDXR ;
banz rrr,*ar7- ;
stm #1000,ar7 ;
stm #4000h,ar6 ;
stm #4500h,ar3 ;
rsbx XF ;
rete
rrr stl b,*ar3+ ;
stl a,*ar6+ ;
rete
trans rsbx XF ;
rete
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -