AnsweredAssumed Answered

UART Recieve SDK 2.0

Question asked by Ben Griffiths on Jan 12, 2017

In my system I'm using the UART as a debuger/verbose tool. (For productions/testing when the target isn't connected via JTAG).

I'm using Free RTOS.

 

My UART task is regularly sending messages out over the UART about the state of the system (e.g. "Application Started", "Battery Level = 3v" etc...) However I also want the UART task to respond to incoming chars/strings. E.g. If the '?' character is received by the uC I want it to respond with (for example) the software version number.

 

I'm sending strings over the UART using UART_RTOS_Send()

However I can't find a way to receive data without (in effect) polling.

 

The example at \boards\frdmkl43z\rtos_examples\freertos_uart basically just echos out any received characters, rather than sending and receiving interdependently. Digging a little deeper, UART_RTOS_Receive() calls UART_TransferReceiveNonBlocking() which in itself doesn't block the task, however the next line xEventGroupWaitBits() is called - this blocks the task until something is received.

 

In pseudo-code I want the uart tasl to do somethign along the lines of:

(Other tasks send messages to this task to transmit things over the UART)

uart_task()

{

  while (1)

  {

    if (message_received_from_another_task)

    {

      convert_that_msg_into_a_string();

      // Now send that message out over the UART

      UART_RTOS_Send();

    }

   

    // Can't use UART_RTOS_Receive() as that blocks the task

    if (something_recieved_from_UART)

    {

      process_that_string();   // This may include sending something back over UART

    }

  }

}

 

Am I missing something or going about this completely the wrong way?

Outcomes