I need to periodically receive a string of RS-232 data about 45 bytes long at 115200 baud but I'm missing some of the bytes later in the string.
If the string I'm receiving is "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", I'll always get the first 16 characters, which makes sense since the UART FIFO is 16 bytes, but I'll miss many of the later bytes, for example, I might only get a few characters from mid-to-later part of the alphabet.
I'm going to lengths to make sure I'm calling UARTGetChar as fast as possible without letting interrupts occur when doing so - please see my code below - but I still miss data. If I slow it down to 9600 I seem to not miss any data, but this is too slow for my needs.
I'm wondering if the only way to do this at 115200 without losing data is to use DMA with UART?
I've configured UART as follows:
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Configure the GPIO Pin Mux for RX GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0); // Configure the GPIO Pin Mux for TX GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_1); // Enable the UART module SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); while(!SysCtlPeripheralReady(SYSCTL_PERIPH_UART0)); // Configure the given serial IO port for the given baud rate and, 8-N-1 operation. UARTConfigSetExpClk(UART0_BASE, sysClockFreq, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); // Enable the RX UART interrupt. IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
And the interrupt handler:
void SerialCommIntHandler(enum SERIAL_COMM_NUM serialCommNum)
{
// Get the interrupt status
uint32_t status = UARTIntStatus(UART0_BASE, true);
// Clear the asserted interrupts
UARTIntClear(UART0_BASE, status);
IntMasterDisable();
// Loop while there are characters in the receive FIFO
while(UARTCharsAvail(UART0_BASE))
{
LogInfo("%c", UARTCharGetNonBlocking(UART0_BASE));
}
IntMasterEnable();
}