📄 dmac2isr.asm
字号:
;*******************************************************************************
; This code runs at the end of every frame of data transferred into the buffer
; from McBSP1 DRR11 (data receive register) by DMA Channel 2. At the end of the
; DMAC2 block, it sets up DMA Channel 3 to transfer the data from the buffer to
; DXR11 (data transmit register) of McBSP1.
;
;
; Author: Scott Bland Date: 03/20/2000
;*******************************************************************************
;equates
DMA_CH3_ELEM_CNT .set 100h
DMA_CH3_NUM_FRM .set 1
DSYNC_REVT1 .set 0101b << 12
DMA3_CTR .set 4141h
;global references
.global _DMAC2ISR ;ISR start label
.global _buffer ;_buffer is start addr of buffer
.global _brd_led_enable ;board led on
.global _brd_led_disable ;and off
.global _currbuff, _first_frame ;processing flags
.global _frame,_flag ;processing flags
.mmregs
DMSA .set 55h ;Subbank Address Register
DMSDI .set 56h ;Subbank Access Register With Autoincrement
DXR11 .set 43h ;McBSP1 data transmit register
DRR11 .set 41h ;McBSP1 data receive register
DMGSA .set 24h ;global reload registers .. source addr
DMSRC3 .set 0Fh ;Subbank address for DMA3 source address register
DMPREC .set 54h ;DMA control
.sect "asmcode"
_DMAC2ISR
PSHM ST0 ;save context
PSHM ST1
PSHM AL
PSHM AH
PSHM AG
PSHM AR4
PSHM AR5
;First, determine which input frame has been completed...
STM #_frame,AR4 ;AR4 holds address of frame count (initialized in .c file)
ADDM #1,*AR4 ;increment frame count (next input frame)
CMPM *AR4,#3 ;Frame 3 ?
BC frame3,TC ;Frame 3
CMPM *AR4,#2 ;Frame 2 ?
BC frame2,TC ;Frame 2
;else, it's Frame 1
frame1:
LD #_buffer,A ;A holds first argument ... address of buffer
BITF *(_flag), #0AAh ;very first frame?
BC send_output, TC ;No, send output frame and process this frame
B process ;process this frame and return
frame2:
LD #_buffer+100h,A ;A holds first argument ... address of buffer
B send_output ;send output frame and process this frame
frame3: ;set frame back to zero
ST #0,*AR4 ;AR4 still holds address of frame count
LD #_buffer+200h,A ;A holds first argument ... address of buffer
b send_output ;send output frame and process this frame
process:
STM #0x100, T ;load buffer size into T
LD #_buffer+0x400, B ;load base address of second output
MAS *(#_currbuff), B ;if current buffer is 0, B = #_buffer + 0x0400
;if current buffer is 1, B = #_buffer + 0x0300
loopback: ;digital loopback
STLM B, AR5 ;AR5 = output buffer address
STLM A, AR3 ;AR3 = input buffer address
NOP
RPT #0xff
MVDD *AR3+, *AR5+
end_process:
XORM #1, *(#_currbuff)
;Determine if this is the very first interrupt (if so, need a dummy write)
STM #_flag, AR5 ;AR5 holds address of flag (initialized in .c file)
CMPM *AR5, #0 ;Test flag=0
BC finish, NTC ;if flag !=0, do nothing
ST #0AAh, *AR5 ;else, set flag to non-zero value
finish:
POPM AR5 ;context restoration
POPM AR4
POPM AG
POPM AH
POPM AL
POPM ST1
POPM ST0
RETE
send_output: ;this routine writes a processed buffer
;to the output
BITF *(DMPREC), #0008h ;poll for DMA3 transfer complete
BC send_output, TC
LD #_buffer+0x300, B ;compute address of output buffer to
MAC *(#_currbuff), #0x100, B ;be used by DMA3 (processed data)
STM #DMSRC3,DMSA ;program DMA3 registers
STLM B ,DMSDI ;source
STM #DXR11,DMSDI ;destination
STM #DMA_CH3_ELEM_CNT-1,DMSDI ;element count
STM #(DMA_CH3_NUM_FRM-1) | DSYNC_REVT1, DMSDI ;frame count
STM #DMA3_CTR, DMSDI ;DMA3 control
ORM #0008h, *(DMPREC) ;enable DMAC 3
B process ;go process just received buffer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -