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.

EK-TM4C1294XL: can't uart transmit interrupt

Part Number: EK-TM4C1294XL

I am trying to send uart4 interrupt

I have initialized uart4 , but do not get transmit interrupt

My code for above is given below:

//-------------------------------------------------------------------------------------------------------------------------------------------------

//==============================================================================
// UART Initialize
//==============================================================================
void UART_INIT(void)
{

SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

GPIOPinConfigure(GPIO_PA2_U4RX);
GPIOPinConfigure(GPIO_PA3_U4TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3);

UARTConfigSetExpClk(UART4_BASE, ui32SysClock, 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));

IntEnable(INT_UART4);

UARTIntEnable(UART4_BASE, UART_INT_TX);

}

//==============================================================================
// UART 4 interrupt
//==============================================================================
void UART4_IntHandler(void)
{
uint32_t ui32Status;

ui32Status = UARTIntStatus(UART4_BASE, true);
UARTIntClear(UART4_BASE, ui32Status);

if(ui32Status & UART_INT_RX)
{
      while(UARTCharsAvail(UART4_BASE))
     { 
         COMM[COMM_232].RxD_TIMEOUT_CNT = 0;

         COMM[COMM_232].RxD_BUF[COMM[COMM_232].RxD_BUF_PTR] = UARTCharGetNonBlocking(UART4_BASE);
         if(++COMM[COMM_232].RxD_BUF_PTR >= 100) COMM[COMM_232].RxD_BUF_PTR = 0;
     }
}


else if(ui32Status & UART_INT_TX)
{
      while(UARTSpaceAvail(UART4_BASE))
     {
           if(COMM[COMM_232].TxD_BUF_PTR > COMM[COMM_232].TxD_END_PTR)
           {
              COMM[COMM_232].TxD_BUF_PTR = 0;
              UARTIntDisable(UART4_BASE, UART_INT_TX);
              UARTIntEnable(UART4_BASE, UART_INT_RX);
           }
         else UARTCharPutNonBlocking(UART4_BASE, COMM[COMM_232].TxD_BUF[COMM[COMM_232].TxD_BUF_PTR++]);

     }
}
}

//==============================================================================
// Main
//==============================================================================
int main(void)

{

ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 20000000);

UART_INIT();

COMM[COMM_232].TxD_BUF[0] = 0x1;
COMM[COMM_232].TxD_BUF[1] = 0x3;
COMM[COMM_232].TxD_BUF[2] = 0x0;
COMM[COMM_232].TxD_BUF[3] = 0x0;
COMM[COMM_232].TxD_BUF[4] = 0x0;
COMM[COMM_232].TxD_BUF[5] = 0xa;
COMM[COMM_232].TxD_BUF[6] = 0x9d;
COMM[COMM_232].TxD_BUF[7] = 0xd1;

COMM[COMM_232].TxD_END_PTR = 7;
COMM[COMM_232].TxD_BUF_PTR = 0;

//UARTCharPutNonBlocking(UART4_BASE, COMM[COMM_232].TxD_BUF[COMM[COMM_232].TxD_BUF_PTR++]);
UARTCharPut(UART4_BASE, COMM[COMM_232].TxD_BUF[COMM[COMM_232].TxD_BUF_PTR++]);

while(1)

{

}

}

//-------------------------------------------------------------------------------------------------------------------------------------------------

I am not sure where I am going wrong. Help needed seriously.

     -karls

  • Before your while() loop, you are only putting one character. There is no Tx interrupt expected under default conditions:

    Let's say your FIFO level is configured at half the buffer (8 bytes), which is the default (but can be changed).
    Say you placed more than those 8 bytes, 12 for example. The hardware is transmitting bytes at your uart speed. When the byte #9 is transmitted, and your FIFO level reaches 8, THAT's when you get the interrupt (to tell your program that there is "enough" free space again, and that you can put another bunch of bytes there).
    Read this thread for a more complete discussion:
    e2e.ti.com/.../2221906

    In your case, if you want to send only 8 bytes, and you have that FIFO buffer with 16 bytes, simple put them all at the same time within one while. Transmission interrupts are useful to let you manage a bigger quantity of bytes.

    Bruno

  • Thank you!
    I was very helpful and able to solve my problem!

    karls