进入串口中断处理程序后,获取中断工作状态后,而程序总是在中断里跑,始终挑不出来,串口的配置已配好.(附程序)
uint32_t ulStatus;
ulStatus = UARTIntStatus(UART0_BASE, false);
uint32_t recv_n = 0;
char c;
int port_id = 0;
unsigned long ulMode;
//
//
//
ulStatus = UARTIntStatus(UART0_BASE, false);
//
//
//
UARTIntClear(UART0_BASE, ulStatus);
//
if( ulStatus & UART_INT_RX || ulStatus & UART_INT_RT ) //
{
for (;;)
{
if (!UARTCharsAvail(UART0_BASE)) break; //
c = UARTCharGetNB(UART0_BASE); //
recv_n++;
if (RxIndex[port_id] < MAX_SIZE)
{
RxData[port_id][RxIndex[port_id]++] = c;
RxData[port_id][RxIndex[port_id]] = ' ';
}
if (recv_n == 11)
break;
}
if ( ulStatus & UART_INT_RT )
{
RxLen[port_id] = RxIndex[port_id];
RxIndex[port_id] = 0;
// Rt0IntNum++;
RxEndFlag[port_id] = true;
uartPuts( 0, RxData[0] );
// Uart0Func();
}
}
if( ulStatus & UART_INT_DMATX )
{
ulMode = uDMAChannelModeGet( UDMA_CHANNEL_UART_TX[port_id] | UDMA_PRI_SELECT );
if(ulMode == UDMA_MODE_STOP)
{
uDMAChannelAssign(UDMA_CH9_UART0TX);
if( DMAlen[port_id] > 1024 )
{
memcpy(DMA_temp[port_id], DMA_tBuff[port_id]+1024, DMAlen[port_id]-1024);
uDMAChannelTransferSet(UDMA_CHANNEL_UART0TX | UDMA_PRI_SELECT,
UDMA_MODE_BASIC, DMA_temp[port_id],
(void *)(UART0_BASE + UART_O_DR), DMAlen[port_id]-1024 );
uDMAChannelEnable(UDMA_CHANNEL_UART0TX);
DMAlen[port_id] -= 1024;
}
}
}
此帖出自
小平头技术问答
一周热门 更多>