Hi @davepfaltzgraff,
I had faced similar issues in the past, and I solved it with a custom implementation based on the SDK, which now works without issues for me.
You can find it on Github: https://github.com/ErichStyger/McuOnEclipseLibrary/tree/master
The implementation is in the following three source files:
https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/config/McuShellUartconfig.h
https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/src/McuShellUart.h
https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/src/McuShellUart.c
Search in the files for the following:
McuShellUart_CONFIG_UART_K22FN512_LPUART0_C3_C4
What I had to do is to properly enable the FIFO of the UART and properly check and reset the flags in the IRQ, code posted below:
void McuShellUart_CONFIG_UART_IRQ_HANDLER(void) {
uint8_t data;
uint32_t flags;
#if McuShellUart_CONFIG_USE_FREERTOS
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
#endif
uint8_t count;
flags = McuShellUart_CONFIG_UART_GET_FLAGS(McuShellUart_CONFIG_UART_DEVICE);
#if McuShellUart_CONFIG_HAS_FIFO
if (flags&kUART_RxFifoOverflowFlag) {
count = 0; /* statement to allow debugger to set a breakpoint here */
}
#endif
/* If new data arrived. */
if (flags&McuShellUart_CONFIG_UART_HW_RX_READY_FLAGS) {
#if McuShellUart_CONFIG_HAS_FIFO
count = McuShellUart_CONFIG_UART_DEVICE->RCFIFO;
#else
count = 1;
#endif
while(count!=0) {
data = McuShellUart_CONFIG_UART_READ_BYTE(McuShellUart_CONFIG_UART_DEVICE);
#if McuShellUart_CONFIG_USE_FREERTOS
(void)xQueueSendFromISR(uartRxQueue, &data, &xHigherPriorityTaskWoken);
#else
McuRB_Put(rxRingBuffer, &data);
#endif
count--;
}
}
McuShellUART_CONFIG_CLEAR_STATUS_FLAGS(McuShellUart_CONFIG_UART_DEVICE, flags|McuShellUART_CONFIG_CLEAR_EXTRA_STATUS_FLAGS);
#if McuShellUart_CONFIG_USE_FREERTOS
if (xHigherPriorityTaskWoken != pdFALSE) {
vPortYieldFromISR();
}
#endif
#if McuLib_CONFIG_CPU_IS_ARM_CORTEX_M && ((McuLib_CONFIG_CORTEX_M==4) || (McuLib_CONFIG_CORTEX_M==7))
/* ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping exception return operation might vector to incorrect interrupt.
* For Cortex-M7, if core speed much faster than peripheral register write speed, the peripheral interrupt flags may be still set after exiting ISR, this results to
* the same error similar with errata 83869. */
__DSB();
#endif
}
I'm using a FreeRTOS Queue for the characters received, and with the above implementation using FIFO and sufficient queue buffer (depending on the receive task priority and handling), I have been able to receive data with and above 115k without issues or buffer overruns.
Notice the possibility in the above code to set a breakpoint or checkpoint in case of buffer overrun: I kept that in the code just in case, but had no need to use it for several years.
I hope this helps,
Erich