为什么开启DMA的串口处理中断,总是在中断跑,跳不出来,附程序(串口里已配置和使能DMA的串口处理中断)
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]] = '\0';
}
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;
}
}
}
|