uart配置dma接收和发送应该都是一样的,可是为什么uart1可以正常运行,而uart2不行。
代码如下:
void
InitUART2Transfer(void)
{
unsigned int uIdx;
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART2);
HWREG(GPIO_PORTD_BASE+GPIO_O_LOCK)=GPIO_LOCK_KEY;
HWREG(GPIO_PORTD_BASE+GPIO_O_CR)=0xff;
ROM_UARTConfigSetExpClk(UART2_BASE, ROM_SysCtlClockGet(), 115200,
UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE);
ROM_UARTFIFOLevelSet(UART2_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8);
ROM_UARTEnable(UART2_BASE);
ROM_UARTDMAEnable(UART2_BASE, UART_DMA_RX | UART_DMA_TX);
HWREG(UART2_BASE + UART_O_CTL) |= UART_CTL_LBE;
ROM_IntEnable(INT_UART2);
uDMAChannelSelectSecondary(UDMA_DEF_USBEP1RX_SEC_UART2RX);
ROM_uDMAChannelAttributeDisable(UDMA_CHANNEL_USBEP1RX,
UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
ROM_uDMAChannelControlSet(UDMA_CHANNEL_USBEP1RX | UDMA_PRI_SELECT,
UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
UDMA_ARB_4);
ROM_uDMAChannelControlSet(UDMA_CHANNEL_USBEP1RX | UDMA_ALT_SELECT,
UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 |
UDMA_ARB_4);
ROM_uDMAChannelTransferSet(UDMA_CHANNEL_USBEP1RX | UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void *)(UART2_BASE + UART_O_DR),
g_ui8RxBufA, sizeof(g_ui8RxBufA));
ROM_uDMAChannelTransferSet(UDMA_CHANNEL_USBEP1RX | UDMA_ALT_SELECT,
UDMA_MODE_PINGPONG,
(void *)(UART2_BASE + UART_O_DR),
g_ui8RxBufB, sizeof(g_ui8RxBufB));
uDMAChannelSelectSecondary(UDMA_DEF_USBEP1TX_SEC_UART2TX);
ROM_uDMAChannelAttributeDisable(UDMA_CHANNEL_USBEP1TX,
UDMA_ATTR_ALTSELECT |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
ROM_uDMAChannelAttributeEnable(UDMA_CHANNEL_USBEP1TX, UDMA_ATTR_USEBURST);
ROM_uDMAChannelControlSet(UDMA_CHANNEL_USBEP1TX | UDMA_PRI_SELECT,
UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE |
UDMA_ARB_4);
ROM_uDMAChannelTransferSet(UDMA_CHANNEL_USBEP1TX | UDMA_PRI_SELECT,
UDMA_MODE_BASIC, tx_buf,
(void *)(UART2_BASE + UART_O_DR),
sizeof(tx_buf));
ROM_uDMAChannelEnable(UDMA_CHANNEL_USBEP1RX);
ROM_uDMAChannelEnable(UDMA_CHANNEL_USBEP1TX);
}
望大神指点一下…
xyz549040622:
使能完时钟后,加个延时看看。