大家好,我在 tm4c129xnczad 微控制器中处理中断驱动 UART 接收,我在 code composer studio 中工作,问题是我没有收到 UART 接收,ISR 处理程序也没有触发,我在下面附上了我的代码
任何 tho
//***************************************************************************** // // The UART interrupt handler. // //***************************************************************************** void UARTIntHandler(void) { uint32_t ui32Status; GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4); // // Get the interrrupt status. // ui32Status = MAP_UARTIntStatus(UART0_BASE, true); // // Clear the asserted interrupts. // MAP_UARTIntClear(UART0_BASE, ui32Status); // // Loop while there are characters in the receive FIFO. // while(MAP_UARTCharsAvail(UART0_BASE)) { // // Read the next character from the UART and write it back to the UART. // MAP_UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE)); } } //***************************************************************************** // // Send a string to the UART. // //***************************************************************************** void UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count) { // // Loop while there are more characters to send. // while(ui32Count--) { // // Write the next character to the UART. // MAP_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++); } } void delayMs(uint32_t ui32Ms) { // 1 clock cycle = 1 / SysCtlClockGet() second // 1 SysCtlDelay = 3 clock cycle = 3 / SysCtlClockGet() second // 1 second = SysCtlClockGet() / 3 // 0.001 second = 1 ms = SysCtlClockGet() / 3 / 1000 SysCtlDelay(ui32Ms * (120000000 / 3 / 1000)); } void delayUs(uint32_t ui32Us) { SysCtlDelay(ui32Us * (120000000 / 3 / 1000000)); } int main(void) { volatile uint32_t ui32Loop; uint32_t ui32SysClock; ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_240), 120000000); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); MAP_GPIOPinConfigure(GPIO_PA0_U0RX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0); MAP_GPIOPinConfigure(GPIO_PA1_U0TX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_1); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); MAP_UARTConfigSetExpClk(UART0_BASE, ui32SysClock, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); MAP_IntEnable(INT_UART0); MAP_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); MAP_UARTCharPutNonBlocking(UART0_BASE, 'a'); // // Enable the GPIO port that is used for the on-board LED. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); // // Check if the peripheral access is enabled. // while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION)) { } SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // // Check if the peripheral access is enabled. // while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF)) { } SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE)) { } // // Enable the GPIO pin for the LED (PN0). Set the direction as output, and // enable the GPIO pin for digital function. // GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_5); GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_6); /*PORTF_DIR |= 0x0000003E; //set PF1, PF2, PF3 as output PORTF_DEN |= 0x0000003E; //enable PF1, PF2, PF3 PORTF_DATA = 0;*/ // // Loop forever. // while(1) { // // Turn on the LED. // //MAP_UARTCharPutNonBlocking(UART0_BASE, 'a'); /*if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_5)) { GPIO_PORTF_AHB_DATA_R |= (GPIO_PIN_4); } else { GPIO_PORTF_AHB_DATA_R &= ~(GPIO_PIN_4); }*/ /* GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_PIN_3); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_5, GPIO_PIN_5); GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_6, GPIO_PIN_6);*/ // // Delay for a bit. // /* for(ui32Loop = 0; ui32Loop < 2000000; ui32Loop++) { }*/ // PORTF_DATA |= (GPIO_PIN_4 | PF2 | PF3); // SysCtlDelay(5000000); delayUs(100); // // Turn off the LED. // // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, 0x0); /*GPIO_PORTF_AHB_DATA_R &= ~((GPIO_PIN_4)); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0x0); GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_6, 0x0); //PORTF_DATA &= ~(GPIO_PIN_4 | PF2 | PF3 );*/ delayUs(100); // SysCtlDelay(5000000); // // Delay for a bit. // /* for(ui32Loop = 0; ui32Loop < 2000000; ui32Loop++) { }*/ } return 0; }请与我分享