哪位大虾帮我看下这个初始化程序,串口发送数据后由DMA自动填入内存中,DMA每重载一次地址时都会固定的丢掉两个字节的数据,初始化程序如下void LinUart0_Init(void)
{
STR_PDMA_T sPDMA;
unsigned short a;
/* Select UART Clock Source From 12Mhz*/
SYS_SelectIPClockSource_1(CLK_CLKSEL1_UART_MASK, CLK_CLKSEL1_UART_HXT);
MFP_UART0_TO_PORTB();// PB4-Rx1 PB5-Tx1
CLK->APBCLK |= CLK_APBCLK_UART0_EN; /* Enable UART0 clock */
CLK->CLKDIV0 &= ~CLK_CLKDIV0_UART_MASK;
CLK->CLKSEL1 = (CLK->CLKSEL1 & ~CLK_CLKSEL1_UART_MASK) | CLK_CLKSEL1_UART_HXT; /* Select 12 Mhz XTAL */
UART0->BAUD =15; /* Baud Rate:230400 OSC:12MHz */
UART0->TLCTL = 0x03; /* Character len is 8 bits */
#if 1
/* CH3: Uart0 RX */
PDMA_EnableChannelClock(PDMAGCR_CSR_CLK3);/* Enable Channel 2 Clock */
sPDMA.SrcAddr = (uint32_t)&(UART0->RBR);
sPDMA.DestAddr = (uint32_t)&RecPlayBuff[0];
sPDMA.SrcCtrl = PDMA_CSR_SAD_FIX; //源地址固定
sPDMA.DestCtrl = PDMA_CSR_DAD_WRAP;
sPDMA.TransWidth = PDMA_CSR_APB_TWS_8BIT;
sPDMA.Mode = PDMA_CSR_IP2MEM;
//共接收的字节数
sPDMA.ByteCnt = 5120;
sPDMA.IsTimeOutEnable = 0;
PDMA_Open(PDMA3, &sPDMA);
PDMA_UART0_RX_TO_CH3();
UART_EnablePDMA(UART0);
PDMA_CHEnableTransfer(PDMA3);
#endif
}
|