This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART0一直进不了中断

Other Parts Discussed in Thread: TM4C123GH6PM, EK-TM4C123GXL

求大家帮忙看看  实在找不出错了,代码是教程实验中的代码,如下

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "driverlib/gpio.h"
//#define PART_TM4C123GH6PM
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "driverlib/interrupt.h"
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif
//*****************************************************************************
//
// 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.
//
UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
}
}

int main(void) {

SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);//50MHz

SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);//启用UART0
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);//启用GPIOA

GPIOPinConfigure(GPIO_PA0_U0RX);//GPIO管脚复用配置
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);//管脚UART功能配置PA0 PA1
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);//启用GPIOF
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
//UART时钟为系统时钟,波特率为115200,数据类型为数据位为8,停止位1,无奇偶校验位
IntMasterEnable(); //enable processor interrupts
IntEnable(INT_UART0); //enable the UART interrupt
UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts

UARTSend((uint8_t *)"Enter text: ", 10);

while (1)
{
if (UARTCharsAvail(UART0_BASE)) UARTCharPut(UART0_BASE, UARTCharGet(UART0_BASE));
}

}

void UARTIntHandler(void)
{
uint32_t ui32Status;

ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status

UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts

while(UARTCharsAvail(UART0_BASE)) //loop while there are chars
{
UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE)); //echo character
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); //blink LED
SysCtlDelay(SysCtlClockGet() / (1000 * 3)); //delay ~1 msec
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); //turn off LED
}
}