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.

UART中断接受数据为什么会卡死在FaultISR函数里?

Other Parts Discussed in Thread: EK-TM4C123GXL

配置UART0为接收到数据产生中断存在数组里,但是每次都会卡死在FaultISR函数里面?

  • 你跟踪看看,最后是哪句调到FaultISR函数里面的,一般不外乎是指针访问出错,地址溢出等

  • 仿真中看到是在串口数据接收中断函数执行到最后一个大括号前面跳进去的

  • 在仿真中看到是在串口通信中断的最后一个括号中跳进去的

  • 对照例程看一下:

    C:\ti\TivaWare_C_Series-2.1.0.12573\examples\boards\ek-tm4c123gxl\uart_echo

    或者把源码贴上来一起看看。

  • 求教一下怎么跟踪哪句FaultISR

  • 仿真,然后程序停在FaultISR的时候看一下link寄存器,这里保存了跳转前的地址。

    其实也不用这么复杂,理顺程序后把问题解决了就行了

  • 源码如下
    //*****************************************************************************

    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/rom.h"
    #include "driverlib/rom_map.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"


    uint8_t RxData[9]={0};

    uint8_t UartRxDatFlag = false;
    uint8_t UartTxIntEnFlag = false;

    uint16_t UartTxLen = 0;
    uint16_t UartTxIndex = 0;


    //*****************************************************************************
    //
    //! \addtogroup uart_examples_list
    //! <h1>UART Polled I/O (uart_polled)</h1>
    //!
    //! This example shows how to set up the UART and use polled I/O methods
    //! for transmitting and receiving UART data. The example receives characters
    //! from UART0 and retransmits the same character using UART0. It can be
    //! tested by using a serial terminal program on a host computer. This
    //! example will echo every character that is type until the return/enter key
    //! is pressed.
    //!
    //! This example uses the following peripherals and I/O signals. You must
    //! review these and change as needed for your own board:
    //! - UART0 peripheral
    //! - GPIO Port A peripheral (for UART0 pins)
    //! - UART0RX - PA0
    //! - UART0TX - PA1
    //
    //*****************************************************************************

    void UART0IntHandler(void)
    {
    uint32_t ui32Status = 0;

    //获取中断状态
    ui32Status = UARTIntStatus(UART0_BASE, true);

    //清除中断标志
    ROM_UARTIntClear(UART0_BASE, ui32Status);

    RxData[UartTxLen ++]=UARTCharGet(UART0_BASE);

    if(UartTxLen ==9)
    {
    UartTxLen =0;
    for(UartTxIndex=0;UartTxIndex<9;UartTxIndex++)
    {
    UARTCharPutNonBlocking(UART0_BASE,RxData[UartTxIndex]);
    // RxData[UartTxIndex]=0;
    }
    // UARTprintf("\n");
    }
    }

    //*****************************************************************************
    //
    // Configure the UART and perform reads and writes using polled I/O.
    //
    //*****************************************************************************
    void INT_UART(void)
    {
    // Enable the peripherals used by this example.

    // The UART itself needs to be enabled, as well as the GPIO port
    // containing the pins that will be used.

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    // Configure the GPIO pin muxing for the UART function.
    // This is only necessary if your part supports GPIO pin function muxing.
    // Study the data sheet to see which functions are allocated per pin.
    // TODO: change this to select the port/pin you are using
    //
    GPIOPinConfigure(GPIO_PA0_U0RX);
    GPIOPinConfigure(GPIO_PA1_U0TX);

    //
    // Since GPIO A0 and A1 are used for the UART function, they must be
    // configured for use as a peripheral function (instead of GPIO).
    // TODO: change this to match the port/pin you are using
    //
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
    //
    // Configure the UART for 115,200, 8-N-1 operation.
    // This function uses SysCtlClockGet() to get the system clock
    // frequency. This could be also be a variable or hard coded value
    // instead of a function call.
    //
    /* UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
    UART_CONFIG_PAR_NONE));*/
    UARTStdioConfig(0, 57600, 16000000);

    ROM_IntEnable(INT_UART0);
    ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);

    // IntPrioritySet(INT_UART0,0x00);

    }

  • 楼主请使用C:\ti\TivaWare_C_Series-2.1.0.12573\examples\boards\ek-tm4c123gxl\uart_echo这个例程的做法对UART进行初始化,接收使用中断方式,发送使用:

    //*****************************************************************************
    //
    // 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.
    //
    ROM_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
    }
    }

    不要在中断中使用UARTprintf