📄 extdma.c
字号:
#include <string.h>
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\def.h"
void _Zdma0XdreqHandshake(void);
#define BUS8 (0)
#define BUS16 (1)
#define BUS32 (2)
#define ENWAIT (1)
#define SRAMBE03 (1)
//PG3 = DMAMODE0
//PG4 = DMAMODE1
//PE4 = nDMASTART
//PE5 = reserved
#define SET_XDREQ16() rPDATG=(rPDATG&~(3<<3))|(0x1<<3)
#define SET_XDREQ1() rPDATG=(rPDATG&~(3<<3))|(0x2<<3)
#define START_XDREQ() {rPDATE=(rPDATE&~(1<<4))|(0x0<<4);\
rPDATE=(rPDATE&~(1<<4))|(0x1<<4);}
//DMAMODE[1:0]: 01b= one time request
// 10b= 16 time requests
#define B1_Tacs (0x0) //0clk
#define B1_Tcos (0x0) //0clk
#define B1_Tacc (0x1) //2clk
#define B1_Tcoh (0x0) //0clk
#define B1_Tah (0x0) //0clk
#define B1_Tacp (0x0) //2clk
#define B1_PMC (0x0) //no page mode
volatile int isZdma0Done;
void __irq IsrZdma0Done(void)
{
rI_ISPC=BIT_ZDMA0;
isZdma0Done=1;
}
void Test_ZDma0Xdreq(void)
{
rBWSCON=rBWSCON&(~0xf0)|(BUS16<<4);
rBANKCON1=((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+(B1_Tacp<<2)+(B1_PMC));
rINTMSK=BIT_GLOBAL;
pISR_ZDMA0=(U32)IsrZdma0Done;
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rPCONF=rPCONF&(~(0xf<<6))|(0xf<<6);//PF3=nXDACK0,PF4=nXDREQ0
rPCONE=rPCONE&(~(3))|(3); //PE0=CLKOUT
rPDATG=rPDATG&(3<<3);
rPCONG=rPCONG&~(0xf<<6)|(5<<6); //PG3,4=OUTPUT
rPDATE=rPDATE&~(1<<4)|(1<<4); //PE4=H
rPCONE=rPCONE&~(3<<8)|(1<<8); //PE4=OUTPUT
_Zdma0XdreqHandshake();
/* lightsurf :del me!!!
for(i=0;i<16;i++)buffer[i]=0xaaaaaaaa;
Uart_Printf("[HandShake,unit,16bit Test,GCS1]\n");
rBANKCON1=(0x6<<9); //tacc=10clk
Uart_Printf("0x2000000:%08x\n",*((volatile unsigned int *)0x2000000));
Uart_Printf("0x2000004:%08x\n",*((volatile unsigned int *)0x2000004));
zdma0Done=0;
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=0x2000000|(1<<30)|(3<<28); // half-word,fix
rZDIDES0=(U32)buffer|(0<<30)|(1<<28); // normal,inc
rZDICNT0=32|(0x0<<30)|(0x0<<28)|(0x1<<26)|(0x0<<24)|(0x3<<22)|(0x0<<21)|(0x1<<20);
//nXDREQ0,handshake,unit,terminal_int,enable DMA,
rZDCON0=0x0; // nXDREQ0 enable.
rPDATG=(0x1<<5)|(0x1<<4); //initiate nDREQ in ALTERA
rPDATG=(0x1<<5)|(0x0<<4);
rPDATG=(0x1<<5)|(0x1<<4);
Uart_Printf("Push any key\n");
Uart_Getch();
//while(zdma0Done==0)Uart_Printf("ZDCCNT0=%08x \r",rZDCCNT0);
for(i=0;i<64;i++)Uart_Printf("%2x,",*((U8 *)buffer+i));
Uart_Printf("\n");
*/
/*
Uart_Printf("[HandShake,unit,8bit Test]\n");
zdma0Done=0;
for(i=0;i<16;i++)buffer[i]=0;
rBWSCON=0x22221210; //8bit
rBANKCON1=(0x2<<9); //tacc=3clk
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=0x2000000|(0<<30)|(1<<28); // byte,inc
rZDIDES0=(U32)buffer|(2<<30)|(1<<28); // normal,inc
rZDICNT0=16|(0x0<<30)|(0x0<<28)|(0x1<<26)|(0x2<<24)|(0x3<<22)|(0x1<<21)|(0x1<<20);
//nXDREQ0,handshake,unit,terminal_int,enable DMA,
rZDCON0=0x0; // nXDREQ0 enable.
rPDATG=(0x1<<5)|(0x1<<4);
rPDATG=(0x1<<5)|(0x0<<4);
rPDATG=(0x1<<5)|(0x1<<4);
while(zdma0Done==0)Uart_Printf("ZDCCNT0=%08x \r",rZDCCNT0);
for(i=0;i<64;i++)Uart_Printf("%2x,",*((U8 *)buffer+i));
Uart_Printf("\n");
*/
/*
Uart_Printf("[Whole,unit,16bit Test]\n");
Uart_Printf("data: x1,xx,x0,xx,x0,xx,......\n");
zdma0Done=0;
for(i=0;i<16;i++)buffer[i]=0xffffffff;
rBWSCON=0x22221220; //16bit
rBANKCON1=(0x2<<9); //tacc=3clk
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=0x2000000|(1<<30)|(1<<28); // half-word,inc
rZDIDES0=(U32)buffer|(2<<30)|(1<<28); // normal,inc
rZDICNT0=32|(0x0<<30)|(0x2<<28)|(0x1<<26)|(0x2<<24)|(0x3<<22)|(0x1<<21)|(0x1<<20);
//nXDREQ0,handshake,unit,terminal_int,enable DMA,
rZDCON0=0x0; // nXDREQ0 enable.
rPDATG=(0x2<<5)|(0x1<<4);
rPDATG=(0x2<<5)|(0x0<<4);
rPDATG=(0x2<<5)|(0x1<<4);
while(zdma0Done==0)Uart_Printf("ZDCCNT0=%08x \r",rZDCCNT0);
for(i=0;i<64;i++)Uart_Printf("%2x,",*((U8 *)buffer+i));
Uart_Printf("\n");
*/
/*
Uart_Printf("[Handshake,Block,16bit Test]\n");
Uart_Printf("data: x1,xx, x?,xx, x0,xx, x0,xx, ...\n");
zdma0Done=0;
for(i=0;i<16;i++)buffer[i]=0xffffffff;
rBWSCON=0x22221220; //16bit
rBANKCON1=(0x2<<9); //tacc=3clk
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=0x2000000|(2<<30)|(1<<28); // half-word,inc
rZDIDES0=(U32)buffer|(2<<30)|(1<<28); // normal,inc
rZDICNT0=(16*4)|(0x0<<30)|(0x0<<28)|(0x2<<26)|(0x2<<24)|(0x3<<22)|(0x1<<21)|(0x1<<20);
//nXDREQ0,handshake,block,terminal_int,enable DMA,
rZDCON0=0x0; // nXDREQ0 enable.
rPDATG=(0x2<<5)|(0x1<<4);
rPDATG=(0x2<<5)|(0x0<<4);
rPDATG=(0x2<<5)|(0x1<<4);
for(i=0;i<20;i++);
rPDATG=(0x2<<5)|(0x1<<4);
rPDATG=(0x2<<5)|(0x0<<4);
rPDATG=(0x2<<5)|(0x1<<4);
for(i=0;i<20;i++);
rPDATG=(0x2<<5)|(0x1<<4);
rPDATG=(0x2<<5)|(0x0<<4);
rPDATG=(0x2<<5)|(0x1<<4);
for(i=0;i<20;i++);
rPDATG=(0x2<<5)|(0x1<<4);
rPDATG=(0x2<<5)|(0x0<<4);
rPDATG=(0x2<<5)|(0x1<<4);
for(i=0;i<20;i++);
while(zdma0Done==0)Uart_Printf("ZDCCNT0=%08x \r",rZDCCNT0);
for(i=0;i<(16*16);i++)Uart_Printf("%2x,",*((U8 *)buffer+i));
Uart_Printf("\n");
*/
/*
Uart_Printf("[HandShake,On the fly Read time,16bit Test]\n");
zdma0Done=0;
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=0x2000000|(1<<30)|(1<<28); // half-word,inc
rZDIDES0=(U32)buffer|(2<<30)|(1<<28); // normal,inc
rZDICNT0=32|(0x0<<30)|(0x0<<28)|(0x3<<26)|( 0x2<<24)|(0x3<<22)|(0x1<<21)|(0x1<<20);
//nXDREQ0,handshake,on_the_fly,read_time,terminal_int,enable DMA,
rZDCON0=0x0; //nXDREQ0 enable.
rPDATG=(0x1<<5)|(0x1<<4); //initiate nDREQ in ALTERA
rPDATG=(0x1<<5)|(0x0<<4);
rPDATG=(0x1<<5)|(0x1<<4);
while(zdma0Done==0);
Uart_Printf("ZDCCNT0=%08x\n",rZDCCNT0);
rPDATG=(0x0<<5)|(0x1<<4);
rINTMSK=BIT_GLOBAL;
rPCONG=savePcong;
rBWSCON=saveBwscon;
rBANKCON1=saveBankcon1;
*/
/*
Uart_Printf("[HandShake,On the fly Write time,16bit Test]\n");
for(i=0;i<16;i++)buffer[i]=0x55555555;
zdma0Done=0;
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=(U32)buffer|(1<<30)|(1<<28); // half-word,inc
rZDIDES0=0x2000000|(2<<30)|(1<<28); // normal,inc
rZDICNT0=32|(0x0<<30)|(0x0<<28)|(0x3<<26)|(0x3<<24)|(0x3<<22)|(0x0<<21)|(0x1<<20);
//nXDREQ0,handshake,on_the_fly,write_time,terminal_int,auto_reload_off,enable DMA,
rZDCON0=0x0; //nXDREQ0 enable.
rPDATG=(0x1<<5)|(0x1<<4); //initiate nDREQ in ALTERA
rPDATG=(0x1<<5)|(0x0<<4);
rPDATG=(0x1<<5)|(0x1<<4);
while(zdma0Done==0);
Uart_Printf("ZDCCNT0=%08x\n",rZDCCNT0);
rPDATG=(0x0<<5)|(0x1<<4);
rINTMSK=BIT_GLOBAL;
rPCONG=savePcong;
rBWSCON=saveBwscon;
rBANKCON1=saveBankcon1;
*/
/*
Uart_Printf("[HandShake,On the fly Write time,16bit Test]\n");
for(i=0;i<16;i++)buffer[i]=0x55555555;
zdma0Done=0;
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=(U32)buffer|(1<<30)|(1<<28); // half-word,inc
rZDIDES0=0x2000000|(2<<30)|(1<<28); // normal,inc
rZDICNT0=32|(0x0<<30)|(0x0<<28)|(0x3<<26)|(0x3<<24)|(0x3<<22)|(0x0<<21)|(0x1<<20);
//nXDREQ0,handshake,on_the_fly,write_time,terminal_int,auto_reload_off,enable DMA,
rZDCON0=0x0; //nXDREQ0 enable.
rPDATG=(0x1<<5)|(0x1<<4); //initiate nDREQ in ALTERA
rPDATG=(0x1<<5)|(0x0<<4);
rPDATG=(0x1<<5)|(0x1<<4);
while(zdma0Done==0);
Uart_Printf("ZDCCNT0=%08x\n",rZDCCNT0);
rPDATG=(0x0<<5)|(0x1<<4);
rINTMSK=BIT_GLOBAL;
rPCONG=savePcong;
rBWSCON=saveBwscon;
rBANKCON1=saveBankcon1;
*/
/*
Uart_Printf("[Whole,On the fly Read time,16bit Test]\n");
for(i=0;i<16;i++)buffer[i]=0xffffffff;
zdma0Done=0;
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=0x2000000|(1<<30)|(1<<28); // half-word,inc
rZDIDES0=(U32)buffer|(2<<30)|(1<<28); // normal,inc
rZDICNT0=32|(0x0<<30)|(0x2<<28)|(0x3<<26)|(0x2<<24)|(0x3<<22)|(0x0<<21)|(0x1<<20);
//nXDREQ0,whole,on_the_fly,read_time,terminal_int,auto_reload_off,enable DMA,
rZDCON0=0x0; //nXDREQ0 enable.
rPDATG=(0x2<<5)|(0x1<<4); //initiate nDREQ in ALTERA
rPDATG=(0x2<<5)|(0x0<<4);
rPDATG=(0x2<<5)|(0x1<<4);
while(zdma0Done==0);
Uart_Printf("ZDCCNT0=%08x\n",rZDCCNT0);
rPDATG=(0x0<<5)|(0x1<<4);
rINTMSK=BIT_GLOBAL;
rPCONG=savePcong;
rBWSCON=saveBwscon;
rBANKCON1=saveBankcon1;
*/
/*
Uart_Printf("[Whole,On the fly Write time,16bit Test]\n");
for(i=0;i<16;i++)buffer[i]=0xffffffff;
zdma0Done=0;
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=(U32)buffer|(1<<30)|(1<<28); // half-word,inc
rZDIDES0=0x2000000|(2<<30)|(1<<28); // normal,inc
rZDICNT0=32|(0x0<<30)|(0x2<<28)|(0x3<<26)|(0x3<<24)|(0x3<<22)|(0x0<<21)|(0x1<<20);
//nXDREQ0,whole,on_the_fly,read_time,terminal_int,auto_reload_off,enable DMA,
rZDCON0=0x0; //nXDREQ0 enable.
rPDATG=(0x2<<5)|(0x1<<4); //initiate nDREQ in ALTERA
rPDATG=(0x2<<5)|(0x0<<4);
rPDATG=(0x2<<5)|(0x1<<4);
while(zdma0Done==0);
Uart_Printf("ZDCCNT0=%08x\n",rZDCCNT0);
rPDATG=(0x0<<5)|(0x1<<4);
rINTMSK=BIT_GLOBAL;
rPCONG=savePcong;
rBWSCON=saveBwscon;
rBANKCON1=saveBankcon1;
*/
}
void _Zdma0XdreqHandshake(void)
{
int i;
static U16 bufDst[16];
static U16 bufSrc[16];
Uart_Printf("[ZDMA0,HandShake,unit,16bit Test]\n");
for(i=0;i<16;i++){bufSrc[i]=i;bufDst[i]=0;}
isZdma0Done=0;
rNCACHBE0=( ( (((unsigned)bufDst+16*4)>>12) +1 )<<16 )|((unsigned)bufDst>>12);
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=(U32)bufSrc|(1<<30)|(1<<28); // half-word,inc
rZDIDES0=(U32)bufDst|((U32)2<<30)|(1<<28); // normal,inc
rZDICNT0=32|(0x0<<30)|(0x0<<28)|(0x1<<26)|(0x2<<24)|(0x3<<22)|(0x1<<21)|(0x1<<20);
//nXDREQ0,handshake,unit,terminal_int,auto-reload,enable DMA,
rZDCON0=0x0; // nXDREQ0 enable,CMD=no_command.
SET_XDREQ16();
START_XDREQ();
while(isZdma0Done==0);//Uart_Printf("ZDCCNT0=%08x \r",rZDCCNT0);
for(i=0;i<16;i++)Uart_Printf("%x,",*((U16 *)bufDst+i));
Uart_Printf("\n");
Cache_Flush();
rNCACHBE0=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -