Menu

#72 FreeRTOS_lpc17xx_uart.c - incorrect TX FIFO level parameter usage

v1.0 (example)
closed-out-of-date
nobody
None
5
2020-02-22
2013-10-04
michaelu
No

issue in FreeRTOS-Products/FreeRTOS-Plus-IO/Device/LPC17xx/FreeRTOS_lpc17xx_uart.c
UART3_IRQHandler() calls ioutilsTX_CHARS_FROM_QUEUE_FROM_ISR()

parameter "xCondition" is "( UART_FIFOLVL_TXFIFOLVL( LPC_UART2->FIFOLVL ) != ( UART_TX_FIFO_SIZE - 1 ) )".
This method of checking FIFO level is incorrect for LPC17xx. There is no way to determine FIFO level in LPC17xx.
UART_FIFOLVL_TXFIFOLVL always return 0;

As result of this when transferring large amounts of data (more then FIFO size - 16 bytes) some data may be lost.

I have temporarily replaced ioutilsTX_CHARS_FROM_QUEUE_FROM_ISR() call by:
"""
Character_Queue_State_t pxCharQueueState = ( Character_Queue_State_t * ) ( ( pxTransferStruct )->pvTransferState );
uint8_t buf[UART_TX_FIFO_SIZE];
uint16_t cnt = uxQueueMessagesWaitingFromISR(pxCharQueueState->xQueue);
if (cnt > UART_TX_FIFO_SIZE) {
cnt = UART_TX_FIFO_SIZE; // to write at once
};
for (int i = 0; i < cnt; i++) {
xQueueReceiveFromISR( pxCharQueueState->xQueue, &buf[i], &xHigherPriorityTaskWoken );
}
UART_Send(LPC_UART2,(uint8_t
)&buf,cnt,NONE_BLOCKING);
"""

Discussion

  • Richard Barry

    Richard Barry - 2020-02-22
    • status: open --> closed-out-of-date
     
  • Richard Barry

    Richard Barry - 2020-02-22

    Being replaced by the Common IO interface.

     

Log in to post a comment.