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/DK-TM4C129X: UARTCharsAvail() declared Implicitly warning

Part Number: DK-TM4C129X

Tool/software: TI-RTOS

I am using TI-RTOS and want to read incoming characters through UART for a short period and if the characters are not available then exit reading.

I have included uart.h to the file and still getting Implicit declaration warning. Is there any thing else I need to include?
I cannot find much information in the TI-RTOS driver documentation.

Please let me know if there is any other way to timeout Uart read.
I tried setting readTimeout in Uart Parameters but for some reason it just keeps repeating the echoing the same character and never times out.

Thanks,
Hardik

  • Hi Hardik,

    UARTCharsAvail() is part of Tivaware and not TI-RTOS so you need to also include:

    #include <driverlib/uart.h>

    And make sure your Tivaware path is included on your project's include options, which will most likely already be set for you if you imported the project.

    Instead of that you could use TI-RTOS' UART driver and use UART_readCancel() to cancel the UART_read(). You can find more info on the UART API here:
    UART API Reference

    Thanks,
    Gerardo

  • Hi Gereado,

    Including the Tivaware library solved the implicit declaration problem.

    However, I am still not able to break out of UART_read() function.

    I am using following code to read data from a peripheral through uart3 and write to other uart.

    while(UARTCharsAvail(Board_UART3)){

        UART_read(uart3, &input, 1);

           UART_write(uart, &input, 1);}

    }

    Other things I tried are as follows:

    1)

     while(1){

       if(UARTCharsAvail(Board_UART3)){

        UART_read(uart3, &input, 1);

           UART_write(uart, &input, 1);}

       else break;

    }

    2)  (To timeout after 5 secs)

    while (Clock_getTicks()< time1+5000) {

    if(UARTCharsAvail(Board_UART3)){

        UART_read(uart3, &input, 1);

           UART_write(uart, &input, 1);}

    else break;

       }

     


    I believe that Uart does not see any characters it is getting stuck in read and waits forever for Characters to become available.
    To resolve this i tried using callback parameter using following line:

     uartParams.readMode = UART_MODE_CALLBACK;

    But using Uart_Mode_callback gives me, "uart/UARTTiva.c", line 301: assertion failure".

    Is there anything else I can try?

    Thanks,
    Hardik

  • Hi Hardik,

    Could you post your UART configuration code, or you project so I can check to make sure the UART is configured correctly.

    Thanks,
    Gerardo
  • Hi Hardik,

    I just tested your project and it's actually working for me, whatever I write to one of my UARTs is being output on the other one. Are you getting the initial prompts you have in there printed in both of your UARTs?

    Thanks,
    Gerardo
  • I am able to read and write to both UARTs perfectly.
    Its just that I need to be able to stop reading UART3 after some time so that I can send other commands.

    Right now, it's waiting forever in UART_read() and the task gets stuck if there is nothing to read.
    So if I have other prompts below the while loop mentioned above, then I never reach those prompts.
  • Hi Hardik,

    I misunderstood what your issue was. I see that you tried setting the mode to callback mode but you saw an assertion. This was because you were not setting your callback function, you would need to declare your function to be called as such:

    void uartReadCallback(UART_Handle handle, void *buffer, size_t num)
    {
        // Do something
    }

    And then you would need to add the following to your parameters:

    uartParams.readCallback = &uartReadCallback;

    Thanks,
    Gerardo