?? dma初始化程序.asm
字號:
.title "test.asm"
; .include "c5416.h"
.mmregs
.def start
.def DMA0_Interrupt
;.sect ".vectors"
stack .usect "stack",100h
.align 0x80 ; must be aligned on page boundary
;.bss temp ,1
;.bss buffer0,2
;.bss buffer1,2
;.bss channel,1
k_sample_num .set 256
temp .usect "ad_vars",1
buffer0 .usect "ad_vars",k_sample_num
buffer1 .usect "ad_vars",k_sample_num
DRR20 .set 0x20
DRR10 .set 0x21
DXR20 .set 0x22
DXR10 .set 0x23
DRR22 .set 0x30
DRR12 .set 0x31
DXR22 .set 0x32
DXR12 .set 0x33
SPSA2 .set 0x34
SPSD2 .set 0x35
SPSA0 .set 0x38
SPSD0 .set 0x39
GPIOCR .set 0x3C
GPIOSR .set 0x3D
CSIDR .set 0x3E
DRR21 .set 0x40
DRR11 .set 0x41
DXR21 .set 0x42
DXR11 .set 0x43
SPSA1 .set 0x48
SPSD1 .set 0x49
DMPREC .set 0x54
DMSA .set 0x55
DMSDI .set 0x56
DMSDN .set 0x57
SPCR11 .set 0x0000
SPCR21 .set 0x0001
RCR1 .set 0x0002
RCR2 .set 0x0003
XCR1 .set 0x0004
XCR2 .set 0x0005
SRGR11 .set 0x0006
SRGR21 .set 0x0007
MCR1 .set 0x0008
MCR2 .set 0x0009
RCERA .set 0x000a
RCERB .set 0x000b
XCERA .set 0x000c
XCERB .set 0x000d
PCR .set 0x000e
RCERC .set 0x0010
RCERD .set 0x0011
XCERC .set 0x0012
XCERD .set 0x0013
RCERE .set 0x0014
RCERF .set 0x0015
XCERE .set 0x0016
XCERF .set 0x0017
RCERG .set 0x0018
RCERH .set 0x0019
XCERG .set 0x001a
XCERH .set 0x001b
;DMA寄存器
DMSRC0 .set 0x0000
DMDST0 .set 0x0001
DMCTR0 .set 0x0002
DMSFC0 .set 0x0003
DMMCR0 .set 0x0004
DMSRC1 .set 0x0005
DMDST1 .set 0x0006
DMCTR1 .set 0x0007
DMSFC1 .set 0x0008
DMMCR1 .set 0x0009
DMSRC2 .set 0x000a
DMDST2 .set 0x000b
DMCTR2 .set 0x000c
DMSFC2 .set 0x000d
DMMCR2 .set 0x000e
DMSRC3 .set 0x000f
DMDST3 .set 0x0010
DMCTR3 .set 0x0011
DMSFC3 .set 0x0012
DMMCR3 .set 0x0013
DMSRC4 .set 0x0014
DMDST4 .set 0x0015
DMCTR4 .set 0x0016
DMSFC4 .set 0x0017
DMMCR4 .set 0x0018
DMSRC5 .set 0x0019
DMDST5 .set 0x001a
DMCTR5 .set 0x001b
DMSFC5 .set 0x001c
DMMCR5 .set 0x001d
DMSRCP .set 0x001e
DMDSTP .set 0x001f
DMIDX0 .set 0x0020
DMIDX1 .set 0x0021
DMFRI0 .set 0x0022
DMFRI1 .set 0x0023
DMGSA0 .set 0x0024
DMGDA0 .set 0x0025
DMGCR0 .set 0x0026
DMGFR0 .set 0x0027
XSRCDP .set 0x0028
XDSTDP .set 0x0029
DMGSA1 .set 0x002a
DMGDA1 .set 0x002b
DMGCR1 .set 0x002c
DMGFR1 .set 0x002d
DMGSA2 .set 0x002e
DMGDA2 .set 0x002f
DMGCR2 .set 0x0030
DMGFR2 .set 0x0031
DMGSA3 .set 0x0032
DMGDA3 .set 0x0033
DMGCR3 .set 0x0034
DMGFR3 .set 0x0035
DMGSA4 .set 0x0036
DMGDA4 .set 0x0037
DMGCR4 .set 0x0038
DMGFR4 .set 0x0039
DMGSA5 .set 0x003a
DMGDA5 .set 0x003b
DMGCR5 .set 0x003c
DMGFR5 .set 0x003d
DMGFR .set 0x0027
DMGDA .set 0x0025
DMGCR .set 0x0026
DMGSA .set 0x0027
.text
start: LD #0,DP
STM #stack+100h,SP
STM #7FFFh,SWWSR
STM #0ffh,PMST
SSBX INTM
;SSBX CMPT
; CALL Sys_Init
STM #0FFFFh,IFR ;IFR的任何一位為1,表示一個未響應的中斷
STM #0040h,IMR ; 開DMA0中斷 如是ST1中的中斷屏蔽位INTM=0,IMR中的某一位是1,表示允許相應中斷
RSBX INTM
; LD #0,temp
STM #temp,AR3 ;AR3指向0x0800
STM #buffer0,AR4 ;AR4指向0x0801
STM #buffer1,AR5 ;AR5指向0x0901
LD #0500h,A
STL A,*AR4 ;AR4所指的地址空間0x0801中的內容為0x0500
LD #0610h,A
STL A,*AR5 ;AR5所指的地址空間0x901中的內容為0x0610
;WAIT: B WAIT
Sys_Init:
;*************McBSP_Init***************
STM #00h,SPSA1
STM #0000h,SPSD1 ;jie shouqi wu xiao
STM #01h,SPSA1
STM #0000h,SPSD1 ;fa song qi wu xiao
STM #06h,SPSA1
STM #83h,SPSD1 ;cai yang lv fashenqi 1
STM #07h,SPSA1
STM #2000h,SPSD1 ;cai yang lv fashenqi 2
STM 02h,SPSA1
STM #40h,SPSD1 ;jie shou kongzhi jicunqi 1
STM 03h,SPSA1
STM #01h,SPSD1 ;jie shou kongzhi jicunqi 2
STM 04h,SPSA1
STM #40,SPSD1 ;fasong kongzhi jicunqi 1
STM 05h,SPSA1
STM #01h,SPSD1 ;fasong kongzhi jicunqi 2
STM 0Eh,SPSA1
STM #0A08h,SPSD1 ;yinjiao kongzhi
NOP
NOP
;*************AD_Init******************
; LD #01h,A
; PORTW *(A),3006h
;
; ST #0h,*(channel)
; LD *(channel),A
; BC L2,AEQ
;
; STM #0xe000,DXR12
; B L3
; L2 STM #0xc000,DXR12
; L3 STL DXR12,DRR11
; LD DRR11,-4,A ;DRR11 de shuju zhuan huan
; STL A,DRR11
; ANDM 0x0ff,DRR11
; AND 0x0ff,DRR11
;*************DMA_Init****************
STM DMSRC0,DMSA ;DMSRC0為通道0源地址寄存器
STM DRR11,DMSDN
STM DMDST0,DMSA
STM #0500h,DMSDN ;目的地址為0500h
STM DMCTR0,DMSA
STM #00FFh,DMSDN ;計數器 緩沖區長度為256個數據
STM DMSFC0,DMSA ;DMSFC0為同步選擇和幀計數寄存器
STM #5000h,DMSDN ;McBSP1 接收同步事件,單字模式,每字16位,每塊一幀
STM DMMCR0,DMSA ;傳遞方式控制寄存器
STM #0C045h,DMSDN ;多幀模式,傳輸完成后 允許中斷 目的地址遞增 源地址不變
STM DMIDX0,DMSA ;DMIDX0為元素地址索引寄存器
STM #0001h,DMSDN ;索引寄存器,遞增1
STM DMGSA,DMSA ;全局源地址重加載寄存器
STM DRR11,DMSDN ;全局重載源地址
STM DMGDA,DMSA ;全局目的地址重加載寄存器
STM #0610h,DMSDN ;全局重載目的地址
STM DMGCR,DMSA ;DMGCR為全局元素計數加載寄存器
STM #00FFh,DMSDN ;全局重載索引
STM DMGFR,DMSA ;全局幀計數加載寄存器
STM #0000h,DMSDN ;全局重載幀計數
STM #0181h,DMPREC ;DMA0優先,選通DMA0
LD #0000h,A
STL A,*AR2
;**************緩沖串口使能********* Wait_McBSP_interrupt
ENDD:
; STM #01h,SPSA1
; STM #0000001001000000b,SPSD1 ; cai yang lv gongzuo
; RPT #20
; NOP
; RSBX XF
; STM #01h,SPSA1
; STM #0000001001000001b,SPSD1 ;fasong youxiao
; STM #00h,SPSA1
; STm #01001100000000001b,SPSD1 ; jie shou youxiao
; STM #01h,SPSA1
; STM #0000001011000001b,SPSD1 ;chansheng zhen tongbu maichong
; NOP
; NOP
; RET
; STM SPCR11,SPSA1 ;等待McBSP1中斷 接收使能
; LD SPSD1,A
; OR #0001h,A
; STL A,SPSD1
; RPT #18
; NOP
STM SPCR11,SPSA1
STM 0x5801,SPSD1
STM SPCR21,SPSA1
STM 0xc1,SPSD1
; STM SPCR20,SPSA1 ;發送使能
; LD SPSD1,A
; OR #0001h,A
; STL A,SPSD1
; RPT #18
; NOP
B ENDD
;***************DMA0_Interrupt**********************
DMA0_Interrupt:
LD *AR2,A
ADD #1,A
STL A,*AR2 ;傳遞個數計數
STM buffer1,AR3 ;重載全局地址,此時AR3指向地址0x0901
STM DMGDA,DMSA ;全局目的地址重加載寄存器
LD *AR3,B ;*AR3中的內容為0x0610
STLM B,DMSDN
STM #temp,AR3 ; 交換地址
LD *AR4,A
STL A,*AR3
LD *AR5,A
STL A,*AR4
LD *AR3,A
STL A,*AR5
STM SPCR21,SPSA1 ;關閉MCBSP1發送通道
LD SPSD1,A
AND #0FFF0h,0,A
STL A,SPSD1
RPT #6
NOP
STM SPCR11,SPSA1 ;關閉McBSP1接收
LD SPSD1,A
AND #0FFF0h,0,A
STL A,SPSD1
STM #0,SPSD1
RPT #6
NOP
RETE ;中斷返回
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -