LM3S中uart初始化只有,只有uart0有用,uart1没数据出来
[复制链接]
我在uart_echo例程基础上增加了uart1,但是uart1没法使用,只有uart0可以用。以下是我的程序,看看有问题不? // // Enable the (non-GPIO) peripherals used by this example. PinoutSet() // already enabled GPIO Port A. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); // // Enable processor interrupts. // IntMasterEnable(); // // Set GPIO A0 and A1 as UART pins. // GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_2 | GPIO_PIN_3); // // Configure the UART for 115,200, 8-N-1 operation. // UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // // Enable the UART interrupt. // IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); IntEnable(INT_UART1); UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT); 以上是主程序中的初始化。
以下是UART1的中断程序: void UART1IntHandler(void) { unsigned long ulStatus; // // Get the interrrupt status. // ulStatus = UARTIntStatus(UART1_BASE, true); // // Clear the asserted interrupts. // UARTIntClear(UART1_BASE, ulStatus); // // Loop while there are characters in the receive FIFO. // while(UARTCharsAvail(UART1_BASE)) { // // Read the next character from the UART and write it back to the UART. // UARTCharPutNonBlocking(UART1_BASE, UARTCharGetNonBlocking(UART1_BASE)); } }
|