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.

TM4C123AE6PM: UART Interrupt not firing.

Part Number: TM4C123AE6PM


Tool/software:

After replacing the MPU's from a prior over-current, the system tick interrupt now works.  Now I'm trying to get a UART interrupt to work.  I set a breakpoint on the ISR and it never traps.  Code:

void UartInterrupt(void) {

 

    const int Error_Mask = 0x00000F00;

    const int Data_Mask  = 0x000000FF;

 

    int IntStatus = UARTIntStatus(UART4_BASE, true);    // Clear interrupt.

    UARTIntClear(UART4_BASE, IntStatus);

    while( ! (UART4_FR_R & UART_FR_RXFE)) {     // Until the FIFO is empty, receive characters.

       int Data_And_Errors = UART4_DR_R;

       int Errors = Data_And_Errors & Error_Mask;

       u8  Char   = Data_And_Errors & Data_Mask;

       if(! Errors) { UARTCharPut(UART4_BASE, Char); }

}

 

int main(void) {

 

    SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_XTAL_20MHZ | SYSCTL_USE_PLL);     // Should be 80MHz

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOC)) {}

    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4);                // Enable UART4 Debug Port.

    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_UART4)) {}

    GPIOPinTypeUART(GPIO_PORTC_BASE, PC_DebugRx_BIT | PC_DebugTx_BIT);

    GPIOPinConfigure(GPIO_PC4_U4RX);

    GPIOPinConfigure(GPIO_PC5_U4TX);

 

    UARTConfigSetExpClk(UART4_BASE, 80000000, 9600,

             ( UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE ));

    UARTFIFOEnable(UART4_BASE);

    UARTIntRegister(UART4_BASE, UartInterrupt);            // Register Interrupt Handler.

    UARTIntEnable(UART4_BASE, UART_INT_RX | UART_INT_TX | UART_INT_OE | UART_INT_FE | UART_INT_RT );

    IntEnable(INT_UART4);

 

    while(true) {}

}

Thanks, Doug

  • Hi Doug,

      Do you have the UART4 connected to an FTDI chip that is then connected to the PC? Or are you connecting UART4 directly to another UART device? In any case, do you see the other end send the data to UART4RX input? In your code, you are just waiting in a loop without sending anything. This is why I think you are waiting for data to come in. The only issue I see in your code is your clock configuration. You are missing SYSCTL_OSC_MAIN in SysCtlClockSet. Your system clock will be wrong with respect to the hardcoded 80000000 you input in UARTConfigSetExpClk. Why don't you first fix up SysCtlClockSet and try again. Also observe UART4RX on the scope and make sure there is a valid input at 9600 baud from its source. 

  • Hi Charles,

    Yes, UART4 is going to an FTDI UART to USB interface.  Yes, I can see the characters that it is transmitting getting to the MPU pin, and I can output characters to UART4 and they display correctly on the terminal emulator so the baud rate and connections are correct.  I added SYSCTL_OSC_MAIN to SysCtlClockSet and I added IntMasterEnable() right below the while(true).  I also have sent a long enough string out (through a circular buffer) to fill the UART FIFO and only the characters that initially filled the FIFO got displayed, the interrupt didn't fire their either.

  • I added IntMasterEnable() right *Before* the while(true).

  • Hi Doug,

      What happens if you disable FIFO? Do you still not get interrupt?

      Can you also show the register dump for UART4?

  • The plot thickens.  If I don't have a breakpoint set in the ISR, it works, if I have a breakpoint in it - it doesn't.  ???  I guess this is a question for the CCS forum?

  • OK, I unchecked "Allow software breakpoints" and now it works.

  • Hi Doug,

      Glad you resolved the issue on your own. You cannot use software breakpoint for debugging code stored on the flash. You can only use software breakpoint if you were running code out of RAM. Software breakpoints require the debugger to modify the instructions. Since the flash is not writable like a RAM, a software breakpoint will not work.

  • Interesting, as I was able to get a breakpoint to work in the SysTick ISR.  I thought that CCS defaulted to using hardware breakpoints until no more were available before using software breakpoints.