?? main.c
字號:
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void __irq Zdma0Done(void);
void Zdma0Int(int srcAddr,int dstAddr,int length,int dw);
volatile int zdma0Done,zdma1Done;
void Main(void)
{
unsigned char *src, *dst;
int i;
unsigned int memSum;
rSYSCFG=SYSCFG_8KB;
#if (PLLON==1)
ChangePllValue(PLL_M,PLL_P,PLL_S);
#endif
Isr_Init();
Port_Init();
Uart_Init(0,115200);
Uart_Select(0);
Delay(0); //calibrate Delay()
Led_Display(7);
Delay(1000); //calibrate Delay()
Led_Display(0);
Delay(5000); //calibrate Delay()
Led_Display(7);
Uart_Printf("\n start \n");
rINTMSK|=BIT_GLOBAL;
pISR_ZDMA0=(int)Zdma0Done;
Uart_Printf("[ZDMA0 MEM2MEM Test]\n");
dst=(unsigned char *)malloc(0x80000);
src=(unsigned char *)malloc(0x80000);
rNCACHBE1=( ( (((unsigned)dst+0x100000)>>12) +1 )<<16 )|((unsigned)dst>>12);
Uart_Printf("dst=%x,src=%x\n",(int)dst,(int)src);
/* Copy by word */
memSum=0;
for(i=0;i<0x80000;i++)
*(src+i)=0x1;
Zdma0Int((int)src,(int)dst,0x80000,2); //word
for(i=0;i<0x80000;i++)
memSum+=*(dst+i);
Uart_Printf("memSum=%8x:",memSum);
if(memSum==0x80000)Uart_Printf("O.K.\n");
else Uart_Printf("ERROR!!!\n");
/* Copy by half-word */
memSum=0;
for(i=0;i<0x80000;i++)
*(src+i)=2;
Zdma0Int((int)src,(int)dst,0x80000,1); //half-word
for(i=0;i<0x80000;i++)
memSum+=*(dst+i);
Uart_Printf("memSum=%8x:",memSum);
if(memSum==0x100000)Uart_Printf("O.K.\n");
else Uart_Printf("ERROR!!!\n");
/* Copy by byte */
memSum=0;
for(i=0;i<0x80000;i++)
*(src+i)=3;
Zdma0Int((int)src,(int)dst,0x80000,0); //byte
for(i=0;i<0x80000;i++)
memSum+=*(dst+i);
Uart_Printf("memSum=%8x:",memSum);
if(memSum==0x180000)Uart_Printf("O.K.\n");
else Uart_Printf("ERROR!!!\n");
Uart_Printf("測試完畢\n");
free(src);
free(dst);
}
void Zdma0Int(int srcAddr,int dstAddr,int length,int dw)
//returns the checksum
{
int time;
zdma0Done=0;
rINTMSK=~(BIT_GLOBAL|BIT_ZDMA0);
rZDISRC0=srcAddr|(dw<<30)|(1<<28); // inc
rZDIDES0=dstAddr|( 2<<30)|(1<<28); // inc
rZDICNT0=length |( 2<<28)|(1<<26)|(3<<22)|(1<<20);
//whole,unit transfer,int@TC,enable DMA
rZDCON0=0x1; // start!!!
Timer_Start(3);//128us resolution
while(zdma0Done==0);
time=Timer_Stop();
Uart_Printf("ZDMA0 %8x->%8x,%x:time=%f\n",srcAddr,dstAddr,length,time*128E-6);
rINTMSK=BIT_GLOBAL;
}
void __irq Zdma0Done(void)
{
rI_ISPC=BIT_ZDMA0; //clear pending
//rI_ISPC; //is needed only when cache=on & wrbuf=on & BSFRD=0
zdma0Done=1;
}
/******************************************************************/
void Isr_Init(void)
{
U32 i;
pISR_UNDEF=(unsigned)HaltUndef;
pISR_SWI =(unsigned)HaltSwi;
pISR_PABORT=(unsigned)HaltPabort;
pISR_DABORT=(unsigned)HaltDabort;
for(i=_RAM_STARTADDRESS;i<(_RAM_STARTADDRESS+0x20);i+=4)
{
*((volatile unsigned *)i)=0xEA000000+0x1FFE;
}
rINTCON=0x5; // Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; // All=IRQ mode
rINTMSK|=BIT_GLOBAL|BIT_EINT3; // All interrupt is masked.
}
void HaltUndef(void)
{
Uart_Printf("Undefined instruction exception!!!\n");
while(1);
}
void HaltSwi(void)
{
Uart_Printf("SWI exception!!!\n");
while(1);
}
void HaltPabort(void)
{
Uart_Printf("Pabort exception!!!\n");
while(1);
}
void HaltDabort(void)
{
Uart_Printf("Dabort exception!!!\n");
while(1);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -