Part Number: TM4C123GH6PM
Hello!
I have quite a big project that consists of many modules. One module is responsible for communication with the host system via UART. I disable FIFO and use one interrupt per sent byte, my problem is that when I use UARTTxIntModeSet(UART_BASE, UART_TXINT_MODE_FIFO) then at some random moment of time interrupt is not fired during the message transmission. It can happen after millions of successful transactions, absolutely randomly. On the other hand, when I use UARTTxIntModeSet(UART_BASE, UART_TXINT_MODE_EOT) everything works fine, but I'm interested in why with the MODE_FIFO such a strange thing occur, and also because I will use FIFO interrupts in my other project.
UART Initialization routine:
void UART_Host_Init(uint32_t clockRate)
{
//
// Enable the GPIO Peripheral used by the UART.
//
SysCtlPeripheralEnable(UART_HOST_PERIPH_GPIO);
//
// Enable UART Host clock
//
SysCtlPeripheralEnable(UART_HOST_CLOCK);
//
// Configure GPIO Pins for UART mode.
//
GPIOPinConfigure(UART_HOST_GPIO_RX);
GPIOPinConfigure(UART_HOST_GPIO_TX);
GPIOPinTypeUART(UART_HOST_GPIO_BASE_PORT, UART_HOST_GPIO_PIN_RX | UART_HOST_GPIO_PIN_TX);
//
// Use the internal 16MHz oscillator as the UART clock source.
//
UARTConfigSetExpClk(UART_HOST, clockRate, UART_HOST_SPEED, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_TWO | UART_CONFIG_PAR_NONE));
UARTFIFODisable(UART_HOST);
//
// If the below line is un-commented, then everything works
//
// UARTTxIntModeSet(UART_HOST, UART_TXINT_MODE_EOT);
//
// Enabling RT - receive time-out, TX, and RX interrupts
//
IntEnable(UART_HOST_INT_INDEX);
UARTIntEnable(UART_HOST, UART_INT_RT | UART_INT_TX | UART_INT_RX);
}
In the main loop:
while(1)
{
//
// Some stuff happening
//
if(msgSent == true)
{
msgSent = false;
if(UARTCharPutNonBlocking(UART_HOST, message[index++]) == false)
{
#ifdef DEBUG
while(1) {};
#endif
}
}
}
UART Interrupt:
UARTIntHandler(void)
{
uint32_t ui32Status;
ui32Status = UARTIntStatus(UART_HOST, true); // get interrupt status
UARTIntClear(UART_HOST, ui32Status); // clear the asserted interrupts
//
// Receiving data
//
if((ui32Status & UART_INT_RT) || (ui32Status & UART_INT_RX))
{
g_ui32UARTIntReceive++;
while(UARTCharsAvail(UART_HOST)) //loop while there are chars
UARTCharGetNonBlocking(UART_HOST); // get the received character
}
//
// Sending data
//
if(ui32Status & UART_INT_TX)
{
g_ui32UARTIntTransmit++;
if(index < LENGTH)
{
if(UARTCharPutNonBlocking(UART_HOST, message[index++]) == false)
{
#ifdef DEBUG
while(1) {};
#endif
}
}
else
{
msgSent = true;
index = 0;
}
}
}