This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/TM4C1230H6PM: Implementing/using hardware flow control in TI RTOS 2.16 on UART1

Part Number: TM4C1230H6PM

Tool/software: TI-RTOS

I have a custom board with TM4C1230H6PM and I have connected a GSM modem to UART1 (Tx, Rx, CTS & RTS).

The GSM modem has some commands to which we get response after 1 - 3 seconds. During this time, I want the processor to run different tasks and only process the response once it is received. (non-blocking)

TI RTOS 2.16 is used in this project and currently we use UART_read() function. But this function requires number of bytes to be read and in our case, it varies from every time we send a command.

Ideally, I want the controller to send a command to the modem, go on to process different tasks, and come back again only after the modem responds. I believe that this can be done using CTS & RTS. But I am unable to find any way in which we can integrate CTS/RTS with TI RTOS to achieve my goal.

Am I missing anything here, or the only way to do this is to implement my own UART driver and interrupt with CTS & RTS?

Thanks
Shashank

  • Hi Shashank,

    I know TivaWare supports flow control for UART, however, I am not sure whether the TI-RTOS drivers support flow control.

    There is a suitable solution without flow control and TI-RTOS drivers.

    Use callback mode for uart and read one character at a time. In your callback, you can either process each byte at a time, or push the data to your main task for analysis.

    Below is the pseudo-code that would push data to your processing task

    // uart task
    Void YourTask(UArg arg0, UArg arg1)
    {
      //1- initialize uart
      //2- configure uart in read callback mode
      //3- perform a first read (with 1 byte length)
      
      while (1)
      {
        // wait for each byte
        Sempahore_pend(uartSemaphore);
        
        // process each byte here
      }
    }
    
    // read callback
    Void UART_Callback_read (UART_Handle handle, void *buffer, int size)
    {
      // store data somewhere for processing
    
      // notify main task
      Semaphore_post(uartSemaphore);
    
      // Read again (with 1 byte length)
      UART_read();
    }

    I hope this helps

    Michel

  • Hi Shashank,

    The UART driver for Tiva devices does not implement support for hardware flow control (RTS/CTS).  You’d need to modify the driver to get this.   

    But as Michel suggests, you may be able to request less with each read.  One tweak to what Michel shows… maybe you can first request the length of the minimum-length response.  And once that is received, optionally read the rest of the response.  If with the first part of the response you can’t tell how much additional data is to be expected, then you may have to use single byte reads until response completion.

    Hope this helps.

    Regards,
    Scott

  • There was a suggested answer and since there has been no active on this thread for more than a week, the suggested answer was marked as verify. Please feel free to select the "Reject Answer" button and reply with more details.
  • Hello,

    As per what Michel Solecki suggested, I implemented the logic for receiving the data ONE byte at a time. I also implemented the logic for resetting the pointer to the buffer.

    After reading about some bytes from UART the stack of the task overflows.

    I am also calling he UART readCancel once I receive the Expected response.

    How can I make sure that stack doesn't overflows?

    Thanks,
    Shashank

  • Hi Shashank,

    Can you show us come code so we can see what you have done that could possibly cause a stack overflow?

    Regards,

    Michel