本帖最后由 taowenyang 于 2015-4-30 14:13 编辑
从内存把数据通过串口发送出去,每次只能发送4字节的数据,超过4个字节程序就卡死不动了,4个字节以内是没有问题的,代码如下
用开发板nano130实验的
// DMA
void DMA_Translate()
{
STR_PDMA_T sPDMA;
PDMA_Init();
PDMA_DISABLE_CH1();
PDMA_EnableChannelClock(PDMAGCR_CSR_CLK1);
sPDMA.SrcAddr = (uint32_t)DestArray;
sPDMA.DestAddr = (uint32_t)&(UART1->THR);//(uint32_t)(&GPIOC->PIN);
sPDMA.SrcCtrl = PDMA_CSR_DAD_INC ;
sPDMA.DestCtrl = PDMA_CSR_SAD_FIX;
sPDMA.TransWidth = PDMA_CSR_APB_TWS_8BIT;
sPDMA.Mode = PDMA_CSR_MEM2IP;
sPDMA.ByteCnt = 4;//PDMA_BUF_LENGTH;// 64;
sPDMA.IsTimeOutEnable = 0;
PDMA_Open(PDMA1, &sPDMA);
PDMA_UART1_TX_TO_CH1();
//PDMA_EnableInt(PDMA1, PDMA_IER_TD);
PDMA_CHEnableTransfer(PDMA1);
UART_EnablePDMA(UART1);
while(!(PDMA1->ISR & PDMA_ISR_TD)); //等待DMA传输完成
PDMA1->ISR=PDMA1->ISR;
UART_DisablePDMA(UART1);
PDMA_Close();
PDMA_DeInit();
}
// 串口设置
int8_t UARTn_Init(void)
{
STR_UART_T sParam;
/* Select UART Clock Source From 12Mhz*/
SYS_SelectIPClockSource_1(CLK_CLKSEL1_UART_MASK, CLK_CLKSEL1_UART_HXT);
// Set UART1 Pin
MFP_UART1_TO_PORTB(); //<PortB4->UART1 RX; PortB5->UART1 TX
// UART串口设置115200, 8, 1, 偶校验
sParam.u32BaudRate = 115200;
sParam.u32cDataBits = DRVUART_DATABITS_8;
sParam.u32cStopBits = DRVUART_STOPBITS_1;
sParam.u32cParity = DRVUART_PARITY_EVEN;
sParam.u32cRxTriggerLevel = DRVUART_FIFO_1BYTES;
sParam.u8EnableDiv16 = DISABLE;
if(UART_Init(UART1, &sParam) != E_SUCCESS)
return FALSE;
//UART_EnableInt(UART1, DRVUART_THREINT);
return TRUE;
}
|