同样的程序在UART0 收发数据,但是在UART1就只能发送不能接收。
初始化
void UARTInit(unsigned int bdr)
{
STR_UART_T sParam1;
DrvGPIO_InitFunction(E_FUNC_UART1);
SYSCLK->CLKSEL1.UART_S = 0;
sParam1.u32BaudRate = bdr; // 115200
sParam1.u8cDataBits = DRVUART_DATABITS_8;
sParam1.u8cStopBits = DRVUART_STOPBITS_1;
sParam1.u8cParity = DRVUART_PARITY_NONE;
sParam1.u8cRxTriggerLevel= DRVUART_FIFO_4BYTES;
DrvUART_Open(UART_PORT1,&sParam1);
SYS->GPBMFP.UART1_nRTS_ALE = 0;
SYS->GPBMFP.UART1_nCTS_nCS = 0;
DrvUART_EnableInt(UART_PORT1, (DRVUART_RLSINT | DRVUART_RDAINT | DRVUART_TOUTINT),UART_INT_HANDLE);
}
接收程序
void UART_INT_HANDLE(uint32_t u32IntStatus)
{
uint8_t bInChar[1]={0xFF};
uint16 i;
while (UART1->FSR.RX_EMPTY == 0)
{
//DrvUART_Read(UART_PORT0, bInChar, 1);
bInChar[0] = UART1->DATA;
i = (pIn+1) % RCV_BUFF_SIZE;
if(i != pOut)
{
RcvBuf[pIn] = bInChar[0];
pIn = i;
RcvCnt = GetValidDataNum();//RcvCnt++;
}
}
} |