我前段时间做了一个UART的DMA传输,非常简单。
rUCON0 = rUCON0 & 0xff3 | 0x8;
/****** DMA0 Initialize *****/
rDISRC0 = (U32)(SEND_ADDR);
rDISRCC0 = (0<<1)|(0<<0); //Src=AHB,Increment
rDIDST0 = (U32)UTXH0; // Tx FIFO address
rDIDSTC0 = (1<<1)|(1<<0); //Dst=APB,Fixed;
rDCON0 = (0<<31)|(0<<30)|(1<<29)|(0<<28)|(0 << 27) | (1 << 24) | (1 << 23) | (1 << 22) | (0 << 20) | (50);
//handshake,Sync=APB,IntEn, unit, single, dst=UART0, HwReqMode, NoAutoReload,Halfword,
rDMASKTRIG0 = (1<<1); //DMA0En
但是后来我改成了Timer的DMA操作IO口,就发生了问题。
//********** Set Timer1 ***********************//
rGPBCON &= ~0xf; //set GPB0 GPB1 as tout0, pwm output
rGPBCON |= 0x8;
rTCFG0 &= ~0xff;
rTCFG0 |= 0; //prescaler = 0+1
rTCFG1 &= ~0xf;
rTCFG1 &= (0<<4); //mux = 1/2 ,timer1
rTCFG1 &= ~(0x7<<20);
rTCFG1 |= (0x2<<20); //DMA 模式
rTCNTB1 = 1000;
rTCMPB1 = rTCNTB1>>1; // 50%
rTCON |= (0xb<<8); //disable deadzone, auto-reload, inv-off, update TCNTB0&TCMPB0, start timer 1
rTCON |= (0xf<<8); //disable deadzone, auto-reload, inv-off, update TCNTB0&TCMPB0, start timer 1
rTCON &= ~(2<<8); //clear manual update bit
// while(rTCNTO3>0);
rTCON |= 0; //clear manual update bit
定时器是有波形
pISR_DMA0=(U32)Dma0Done;//DMA0的中断服务程序
rr: Uart_Printf("DMA is enter!\n");
Tx = (U32 *)0x30000000;
for(i = 0;i < 0x8; i++)
* Tx++ = ((i % 2)<<1);
Tx = (U32 *)0x30000000;
rDISRC0=(U32)Tx;
rDISRCC0=(0<<1)|(0<<0); // inc,AHB目的为AHB,increased
rDIDST0 =(U32) 0x56000034;//GPDDAT Adress
rDIDSTC0=(1<<1)|(1<<0); // inc,AHB源来自于APB,fixed
rDCON0=(0<<31)|(1<<30)|(1<<29)|(1<<28)|(1<<27)|(3<<24)|(0<<23)|(0<<22)|(1<<21)|(0<<20)|8;
ClearPending(BIT_DMA0);
rDMASKTRIG0 = (1<<1); //DMA0En
//******************************************************//
while(DMA_END == 0);
Uart_Printf("DMA is Over!\n");
// rINTMSK |= (0x1<<11); // Close timer 1
// rDMASKTRIG0 = (1<<2); //DMA0En
DMA_END = 0;
goto rr;
发现DMA根本就没有执行。
static void __irq Dma0Done(void)
{
// Tx=(unsigned int *)0x30000000;
ClearPending(BIT_DMA0);
DMA_END = 1;
//rDISRC0 =(int) Tx;
}
请高手帮助。万分感谢!
[ 此帖被libailiang在2010-04-26 16:07重新编辑 ]