Timeouts in LPUART with FreeRTOS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timeouts in LPUART with FreeRTOS

1,852 Views
andrew_walsh
Contributor II

Hello,

I'm currently planning to use the LPUART FreeRTOS driver (fsl_lpuart_freertos.*) from the MCUXpresso SDK, but I've noticed that it is not possible to specify a timeout. This appears to be the case in 2.5.0, which I think is the latest (dated 11th Jan 2019).

For example, inside the function LPUART_RTOS_Send(), there is a call to LPUART_TransferSendNonBlocking(), followed by a call to the FreeRTOS xEventGroupWaitBits(), which is as I might expect. The problem, however, is that a hardcoded value, portMAX_DELAY is passed for the parameter xTicksToWait, which I think means it will wait forever.

Would NXP consider modifying the SDK, providing an extra parameter to LPUART_RTOS_Send() which would allow this wait time to be specified? If xEventGroupWaitBits() then returns with no event bits set, LPUART_RTOS_Send() would call LPUART_TransferAbortSend(), perhaps?

If this change was made, I think similar modifications would also be needed in LPUART_RTOS_Receive().

Many Thanks,

Andrew.

0 Kudos
4 Replies

1,536 Views
BlackNight
NXP Employee
NXP Employee

Hi Andrew,

you might have a look at the files in mcuoneclipse/uart.c at master  · GitHub 

where it implements a simple non-blocking UART driver with FreeRTOS.

I hope this helps,

Erich

0 Kudos

1,347 Views
Meera_123
Contributor II

Hiii I tried your code https://github.com/ErichStyger/mcuoneclipse/blob/f2a1361e8a49cc0a2428618796fde21d559cc304/Examples/M... 

void UART_Init(void) {
  MSG_Init();
  if (xTaskCreate(UartTask,      /* pointer to the task                      */
          "UartTask",            /* task name for kernel awareness debugging */
          500/sizeof(portSTACK_TYPE),  /* task stack size                          */
          NULL,                      /* optional task startup argument           */
          tskIDLE_PRIORITY+1,       /* initial priority                         */
          NULL /* optional task handle to create           */
          ) != pdPASS)
  {
      for(;;) {}
  }
  MSG_SendStringTxQueue("AT\r");
  MSG_SendStringTxQueue("AT+CSQ\r");
}

Then it transmits both the string together("AT\rAT+CSQ\r"). I checked here MSG_GetStringTxQueue(localBuf, sizeof(localBuf)); and gives response of first string. 

0 Kudos

1,536 Views
andrew_walsh
Contributor II

Hi Erich,

Thanks for this, and sorry for the delay of my reply; I'll take a look.

I am thinking, in any case, that I'll have to modify the MCUXpresso API, but I was hoping that NXP would consider modifying the standard API.

Best regards,

Andrew.

0 Kudos

1,536 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Andrew:

Thanks for your good suggestion, I will issue a feature request to the develop team.

Regards

Daniel

0 Kudos