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.

  • Resolved

RTOS/EK-TM4C123GXL: UART_read() to receive data continuously.

Part Number: EK-TM4C123GXL

Tool/software: TI-RTOS

Hello,

I am working on interfacing multiple sensors to TM4C123G microcontroller and read the data via UART and store it in a buffer and transmit the same via USB interface. I am facing issues in reading the data via UART, it just returns nothing when I try to read and blocks my next statements. Following is a snippet of the code,

Void echoFxn(UArg arg0, UArg arg1)
{

    uart_multiple_init();
    while(1)
    {
        //UART_read(uart1, a, sizeof(a));
       // UART_read(uart2, c, sizeof(c));
        UART_read(uart3, b, sizeof(b));
        UART_write(uart3, b, sizeof(b));
    }

}

static void uart_multiple_init()
{
     //Create a UART with data processing off.
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;

    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
        System_printf("NOT opened");
        System_flush();
         //Turn on user LED
        GPIO_write(Board_LED0, Board_LED_ON);
        System_abort("Error opening the UART");
    }

    UART_Params_init(&uartParams1);
    uartParams1.writeDataMode = UART_DATA_BINARY;
    uartParams1.readDataMode = UART_DATA_BINARY;
    uartParams1.readReturnMode = UART_RETURN_FULL;
    uartParams1.readEcho = UART_ECHO_OFF;
    uartParams1.baudRate = 115200;
    uart1 = UART_open(Board_UART1, &uartParams1);

    if (uart1 == NULL) {
        System_printf("UART1 NOT OPEN");
        System_flush();
        // Turn on user LED
        GPIO_write(Board_LED0, Board_LED_ON);
        System_abort("Error opening the UART");
    }

    UART_Params_init(&uartParams2);
    uartParams2.writeDataMode = UART_DATA_BINARY;
    uartParams2.readDataMode = UART_DATA_BINARY;
    uartParams2.readReturnMode = UART_RETURN_FULL;
    uartParams2.readEcho = UART_ECHO_OFF;
    uartParams2.baudRate = 115200;
    uart2 = UART_open(Board_UART2, &uartParams2);

    if (uart2 == NULL) {
        System_printf("UART2 NOT OPEN");
        System_flush();
         //Turn on user LED
        GPIO_write(Board_LED0, Board_LED_ON);
        System_abort("Error opening the UART");
    }

    UART_Params_init(&uartParams3);
    uartParams3.writeDataMode = UART_DATA_BINARY;
    uartParams3.readDataMode = UART_DATA_BINARY;
    uartParams3.readReturnMode = UART_RETURN_FULL;
    //uartParams3.readEcho = UART_ECHO_OFF;
    uartParams3.baudRate = 115200;
   // uartParams.readMode = UART_MODE_CALLBACK;
   // uartParams.readCallback  = readCallback;
    uart3 = UART_open(Board_UART3, &uartParams3);

    if (uart3 == NULL) {
        System_printf("UART3 NOT OPEN");
        System_flush();
         //Turn on user LED
        GPIO_write(Board_LED0, Board_LED_ON);
        System_abort("Error opening the UART");
    }

}

I request someone to help me on this, I need atleast one UART to receive the data, so that I can solve other UART receive. 

  • It looks like you are not using TIVAWare but Energia which is a 'duino like platform. You'd be better off asking on an Energia specific forum.

    Robert
  • In reply to Robert Adsett:

    I am building it in CCS 7.3 and on TI-RTOS for TIVA-2.16. I am sure it is not an Energia code.
  • In reply to Nitihin N:

    Then it's unique to TI-RTOS. You'd be better off to try in that forum.

    Or it could be your own invention. In that case you'd be better off using TIVAWare

    Robert
  • In reply to Robert Adsett:

    uartecho.c

    Robert,

    If it was my invention I would not be finding a help. I request you to please look into the code before making such nasty comments.

    Thank you,

  • In reply to Nitihin N:

    My friend - Robert's comment cannot qualify as, "nasty."     He has presented TWO valid alternatives - for your consideration.

    Now "neither" alternative met  your liking - and while that is "fair" -  such suggestions prove, "far from nasty!"

    For the record - I too looked at your code - saw (none) of the "normal" UART Config & Set-Up Code - which suggests that, "Such necessary data is handled w/in the RTOS."     Neither Robert nor myself use a "vendor restricted" RTOS - thus we can offer "no insights" - in that regard.

    No case has been made for, "Use of the RTOS."       There are powerful code examples w/in the TivaWare API - very well illustrating the (necessary) configuration & set-up of multiple UARTs - which are sure to assist your efforts...         Note that the RTOS adds a "layer of complexity" - which should enter into your "design consideration."

  • In reply to cb1_mobile:

    Hello Nitihin,

    I already alerted the TI-RTOS to your post.

    Robert, there is no TI-RTOS forum anymore, customers must post into the device specific forums and then we have an internal system to alert the TI-RTOS team about such threads. Nitihin has posted this in the correct forum and provided plenty of detail for the RTOS team as well.

    Best Regards,

    Ralph Jacobi

  • In reply to cb1_mobile:

    Okay, I have configured the multiple UART's in the source file EK_TM4C123GXL.c

    and in header file EK_TM4C123GXL.h

    But my issue is, even after these configurations UART_read function is not reading any data. The configurations and codes TIVAware which you are speaking is bare metal implementation. I am looking something towards an RTOS implementation. I hope this is more clear.

    Thank you.

  • In reply to Ralph Jacobi:

    Hello Nitihin,

    Also looking at your code vs the example TI-RTOS project provided a few comments:

    1) If you are having issues with reading data, I advise starting with just one UART channel both in configuration and in read attempts. Once you have it working for one, then move to the others.

    2) You don't seem to have a declaration for the 'b' variable/buffer used by

    UART_read(uart3, b, sizeof(b));

    Can you elaborate that better? Also I'd advise using a more descriptive name...

    3) Are you sure the device you are trying to read from will support 115200kbps baud by default? You may need to use something slower like 9600 to start.

    4) Are you checking the return value from UART_open() to make sure they are opening correctly?

    5) Did you use the Board_initUART(); in your main function? If so, have you checked to see that you have the correct UART ports opened? The default function will only initialize UART0, so you need to modify the EK_TM4C123GXL.c file for your project to add more ports. (More reason to use only one port, specifically UART0, for starters)

    Best Regards,

    Ralph Jacobi

  • In reply to Ralph Jacobi:

    Hi Nitihin,

    Looks like you answered my question 5) with the post you provided while I was writing my own, though I would still urge to start with just a *single* UART channel until you have read working and then expand from there. Please do look through my questions/comments 1 through 4.

    Best Regards,

    Ralph Jacobi

  • In reply to Ralph Jacobi:

    Ralph Jacobi
    Robert, there is no TI-RTOS forum anymore, customers must post into the device specific forums and then we have an internal system to alert the TI-RTOS team about such threads.

    Considering few here have any expertise in the TI RTOS that is unfortunate. I suspect short-serving the RTOS community and overloading the device community is likely to pay dividends.

    Robert

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.