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/CC3200SDK: UART blocking mode read timeout

Part Number: CC3200SDK

Tool/software: TI-RTOS

Hi,

I am finding some difficulty with with UART blocking mode read timeout.

For UART blocking mode read, function is UARTCharGet() in this function only argument is for passing the base.

Is it possible to modify this function so that i can add timeout to this function or is there any other method available for UART blocking mode read with timeout.

Thanks and Regards, 

  • Neville,

    I will look into this and get back to you on monday.

    Thanks,

    Vince Rodriguez
  • Hi,

    You should use non blocking function and add there your own timeout, something like that:

    while (timeout--) {
     c = UARTCharGetNonBlocking();
     if (c != -1) return c;
     sleep(1);
    }
    

    Jan

  • Hi,

    Thanks for the reply.

    For UARTCharGetNonBlocking() function UART ISR is required, i am modifing UART ISR for application purpose because of this reason in want to use UARTCharGet() function with time out.

    for blocking mode timeout is not possible?

    Thanks and Regards,
  • Hi,

    No, for UARTCharGetNonBlocking() is not necessary to us UART ISR. Just compare code of UARTCharGetNonBlocking() and UARTCharGet():

    long UARTCharGetNonBlocking(unsigned long ulBase)
    {
        //
        // Check the arguments.
        //
        ASSERT(UARTBaseValid(ulBase));
    
        //
        // See if there are any characters in the receive FIFO.
        //
        if(!(HWREG(ulBase + UART_O_FR) & UART_FR_RXFE))
        {
            //
            // Read and return the next character.
            //
            return(HWREG(ulBase + UART_O_DR));
        }
        else
        {
            //
            // There are no characters, so return a failure.
            //
            return(-1);
        }
    }
    long UARTCharGet(unsigned long ulBase)
    {
        //
        // Check the arguments.
        //
        ASSERT(UARTBaseValid(ulBase));
    
        //
        // Wait until a char is available.
        //
        while(HWREG(ulBase + UART_O_FR) & UART_FR_RXFE)
        {
        }
    
        //
        // Now get the char.
        //
        return(HWREG(ulBase + UART_O_DR));
    }

    Jan

  • Hi,

    Thanks for the reply, this will solve my issue.

    Thanks and regards