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

📄 dma.asm

📁 电子元件资料-170M-pdf版.zip
💻 ASM
字号:

/*
DMA.ASM         ADSP-21065L EPORT 16/32 bit packing
GGL, Analog Devices, Inc. 	 7/19/00

This code is a simple example of getting 16 bit floating point data 
from SDRAM packing it to 32 bits and using dma to get it 
into internal memory.  Once in internal memory, the 
data is accessed as short word and operated on and 
sent back to internal memory. 

*/
#define N 4			
#include "def21065l.h"

.section/DM     seg_dmda;
.VAR dest[N];	
/* This is your destination buffer in internal memory which resides in normal word space */


.section/PM seg_sdram;
.VAR source[2*N]=0x1111, 0x2222, 0x3333, 0x4444, 0xAAAA, 0xBBBB, 0xCCCC, 0xDDDD;	
/* This is the sample 16 bit data from an external sdram */



.section/pm 	seg_rth;
/* This is the interrupt vector table */
Reserved_1:     rti; nop; nop; nop;
Chip_Reset:     idle; jump start; nop; nop;
Reserved_2:     rti; nop; nop; nop;
stack_ov:  	  	rti; nop; nop; nop;
timerhi:   		rti; nop; nop; nop;
Vector:		    rti; nop; nop; nop;
IRQ2:    		rti; nop; nop; nop;
IRQ1:  		    rti; nop; nop; nop;
IRQ0:  		    rti; nop; nop; nop;
Reserved_3:     rti; nop; nop; nop;
sport0r:    	rti; nop; nop; nop;
sport1r:   	    rti; nop; nop; nop;
sport0t:    	rti; nop; nop; nop;
sport1t:     	rti; nop; nop; nop;
Reserved_4:     rti; nop; nop; nop;
Reserved_5:     rti; nop; nop; nop;
EP0:     		nop; nop; rti; nop;
EP1:     		rti; nop; nop; nop;


.section/pm 	seg_pmco;
/*______________________start of main routine__________________________*/
start:
		ustat1=937;					/*refresh rate*/
		dm(SDRDIV)=ustat1;
		ustat1=dm(IOCTL);			/*mask in SDRAM settings*/
		bit set ustat1 SDPSS|SDBN2|SDBS3|SDTRP3|SDTRAS5|SDCL2|SDPGS256|SDDCK1;
		dm(IOCTL)=ustat1;			/*initialize sdram*/


		/* enable interrupts here */
		bit set MODE1 IRPTEN;		/* enable global interrupts here */
		bit set IMASK EP0I; 	/* enable eport interrupts here */
			
							
/* must set up II IM and C register in memory bufffer ; then enable the channel with DEN in DMAC */	
/* dma channel 8 is external port buffer 0 */
	
	r0=0; dm(DMAC0)=r0;				/*clear DMA register*/
	r0 = 1; dm(IMEP0) = r0;         /* set DMA internal memory DMA modifier to 1*/
	dm(EMEP0)=r0; 					/* set DMA external memory DMA modifier to 1*/
	r0 = N;	dm(CEP0) = r0; 			/*set internal  count to N */
	r0=2*N; dm(ECEP0)=r0;			/*set external DMA count to 2N */
	r0=dest; dm(IIEP0) = r0;  		/* Write internal index pointer for dest */
	r0=source; dm(EIEP0)=r0;		/*Write External DMA buffer Index pointer for source */	
	r0=0x0241; dm(DMAC0)=r0; 		/* enable DMA channel, master mode, 16/32bit packing */

wait1: idle;
	/* when this dma completes you will have the 16 bit words that were stored in SDRAM 
	packed to 32 bit words in external memory */

	/* the ISR only has an RTI in it, so after the dma is complete 
	the program flow will continue in the next instruction */



/* find the first address of the data buffer and convert it to short word */
r0=dest;
r1=ashift r0 by 1; /* arithmetically shifting a normal word address to the left produces the short word address of the LSW */

/* initialize dags to the short word buffer */
b0=r1;	
m0=1;
l0=2*N;

/* operate on the short word data and return to short word space */

r0=dm(i0,m0); f0=funpack r0; /* read the short word floating point data to a register and then unpack it */
r1=dm(i0,m0); f1=funpack r1; 
f2=f0*f1; r2=fpack f2;	/* multiply f0 and f1 and then pack it back into a 16 bit floating point word */
dm(i0,m0)=r2;	/* send the 16 bit result out to memory */

r3=dm(i0,m0);	/* read 16 bit fixed point value */
r4=dm(i0,m0);

r5=r3+r4;		/* fixed point add */
dm(i0,m0)=r5;	/* send to 16 bit result out to memory */

wait2:   jump wait2;



⌨️ 快捷键说明

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