这是我的 UART 代码。 当我更改 uart1中断时、它不起作用。 但 uart0会出现问题。 我的错在哪里?
谢谢
#include #include include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "driverlib/debug.h" #include "driverlib/fpu.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h" #include "driverlib.utils/idio.ide"#include "driverlib.idio.ide"#include "#drievidio.idio.ide"#include "u.ide"#include "u.idio.ide"#include "u.idio.ide"#.ide"#include "u.u.ide"#include "u.u.u.u.ide"# ROM_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOA); ROM_SysCtlPeripheralEnable (SYSCTL_Periph_UART0); ROM_GPIOPinConfigure (GPIO_PA0_U0RX); ROM_GPIOPinConfigure (GPIO_PA1_U0TX); ROM_GPIOPinTypeUART (GPIO_Porta_base、GPIO_PIN_0 | GPIO_PIN_1); UARTClockSourceSet (UART0_BASE、UART_CLOCK_PIOSC); UARTStdioConfig (0、115200、16000000); } void ConfigureUART1 (void) { SysCtlPeripheralEnable (SYSCTL_Periph_GPIOB); SysCtlPeripheralEnable (SYSCTL_Periph_UART1); GPIOPINConfigure (GPIO_PB0_U1RX);GPIOPINPT1_UTOP1TB (GPIOPINTPUT1_UART1);GPIOPINTPINTPUT_UTO_UTPUT1 (GPIOPINTPUT_UT1) GPIO_PIN_0 | GPIO_PIN_1); UARTClockSourceSet (UART1_BASE、UART_CLOCK_PIOSC); UARTConfigSetExpClk (UART1_BASE、16000000、115200、(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable (UART1_BASE); } //********* // // UART 中断处理程序。 //// ***************** 空 UARTIntHandler (空) { 无符号长整型 ulStatus; //获取中断状态。 ulStatus = ROM_UARTIntStatus (UART1_BASE、TRUE); //清除已发出的中断。 ROM_UARTIntClear (UART1_base、ulStatus); //在接收 FIFO 中有字符时循环。 while (ROM_UARTCharsAvail (UART1_base)){ //从 UART 读取下一个字符并将其写回 UART。 ROM_UARTCharPutNonBlocking (UART1_base、ROM_UARTCharGetNonBlocking (UART1_base)); } GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_2、GPIO_PIN_2); SysCtlDelay (SysCtlClockGet ()/(1000 * 3)); GPIOPinWrite (GPIO_PORTF_BASE、GPIO_PIN_2、0); } // // //向 UART 发送字符串。 //// ***************** void UART0Send (const uint8_t * pui8Buffer、uint32_t ui32Count) { while (ui32Count---) { ROM_UARTCharPutNonBlocking (UART0_BASE、* pui8Buffer++); } } 空 UART1发送(const uint8_t * pui8Buffer、uint32_t ui32Count) { while (ui32Count---) { ROM_UARTCharPutNonBlocking (UART1_base、* pui8Buffer++); } } //********* // //此示例演示了如何将一串数据发送到 UART。 //// ***************** int main (void) { ROM_FPUEnable(); ROM_FPULazyStackingEnable(); ROM_SysCtlClockSet (SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHz); ROM_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF); //为 LED 启用 GPIO 引脚(PF2)。 ROM_GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE、GPIO_PIN_2); ConfigureUART0(); ConfigureUART1 (); ROM_IntMasterEnable(); ROM_IntEnable (INT_UART1); ROM_UARTIntEnable (UART1_base、UART_INT_RX | UART_INT_RT); //提示输入文本。 UART0Send ((uint8_t *)"\033[2JEnter 文本:"、16); UART1Send ((uint8_t *)"UART1\n"7); //UART2Send (((uint8_t *)"UART2\n"r、 7); while (1) { } }