Tool/software:
I am currently using freeRTOS on the TM4C129ENCPDT microcontroller. To save power, I am using deep sleep in the idle hook as follows:
void vApplicationIdleHook( void ) { SysCtlDeepSleep(); }
My UART configuration is: BAUD 57600, the UART clock is PIOSC at 16 Mhz.
SysCtlPeripheralEnable(UART0_BASE); UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); UARTConfigSetExpClk(UART0_BASE, 16000000, 57600, (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE | UART_CONFIG_WLEN_8)); UARTEnable(UART0_BASE); IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
In the UART interrupt handler, I am copying bytes received into a freeRTOS queue (another task will process the queue):
void UARTIntHandler(void) { // Get the interrupt status. uint32_t status = UARTIntStatus(UART0_BASE, true); // Clear the asserted interrupts. UARTIntClear(UART0_BASE, status); portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; while(UARTCharsAvail(UART0_BASE)) { char c = UARTCharGetNonBlocking(UART0_BASE); // Read the next character from the UART and write it into the UART buffer xQueueSendFromISR(UARTBytesQueue, &c, &xHigherPriorityTaskWoken); } portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
My issue is: When I send a message longer than 16 bytes to the MCU, only the first 16 bytes are received properly. I suspect this is due to the internal UART FIFO buffer being 16 bytes, and my code takes too long to wake from deep sleep mode, thus the UART FIFO buffer fills up and subsequent bytes are lost. The problem does not occur if I use SysCtlSleep() instead of SysCtlDeepSleep().
Is there a way to increase the UART FIFO buffer size? If not, how could I work around this issue to ensure that bytes received from UART are not lost when the MCU is waking up? I would like to enter deep-sleep when the processor is idle, yet it seems like I cannot wake from deep sleep fast enough before the UART FIFO fills up.