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. 

  • In reply to Nitihin N:

    Nitihin N
    If it was my invention I would not be finding a help.

    You'd be surprised how many believe otherwise.

    Nitihin N
    such nasty comments.

    !??!

    Robert

  • In reply to Robert Adsett:

    Somehow "KISS" has, "entered my mind?" Multiple Sensors have been mentioned - yet is each/every such 'Sensor" outputting via a CMOS -level UART. (it is my experience that "most such sensors" output via I2C or SPI - UART proves much more rare.)

    No mention is made of the "separation between such sensors and poster's MCU." It is possible that: if the sensors ARE UART-based - they may employ some form of "line driver" (to greatly expand their communication range) and such line drivers - if not expected & properly safeguared via "matching line drivers @ the MCU" - subject the MCU to (almost) certain "death/destruction."

    Some such "Sensor Data" - especially in light of, "No Sensor Data received" - IS very much required...
  • In reply to cb1_mobile:

    Nitihin,

    Are you using a Launchpad or a custom board? If you are using a custom board, can you hook a scope to see if the UART is transmitting/receiving anything?

    Can you confirm the other UARTs are working? Also, can you try UART3 without the USB. It looks like both USB0 and UART3 use PC6 and PC7, so let's rule out any funny-business with the USB.

    Todd
  • In reply to Ralph Jacobi:

    Hello Ralph,

    1) I have checked with single UART also and it is working fine.

    2) Declaration of variable 'b' is done globally and it is an array of type integer. The UART receive data has to be stored in this buffer.

    3) The sensor module (is a BLE module transmitting the data which it has received via UART) is capable of sending the data at 115200kbps. I would check again with the UART transmit is happening.

    4) All the UART modules are opening correctly, I have checked it using breakpoints and I have also put a check status that if it returns NULL then the system would abort.

    Though i would check the individual functionality again, is it not working because does it have to do something  with both UART and USB working together? 

    Thank you.

  • In reply to ToddMullanix:

    Hello,

    I am uisng Launchpad and I have checked that the UART is transmitting the data. I have checked individually that all the UART's are working. My doubt is that have I done all the configurations/definitions/declarations correct? I have attached the codes in my previous comments.
  • In reply to Nitihin N:

    Can you confirm that UART3 is working properly without the USB involved?
  • In reply to ToddMullanix:

    Hello,

    I checked that whether the data is transferred via UART or not on the sensor side and the sensor is transferring the data. Secondly, I checked with the data receiving side across UART3 Channel and it is not working, Infact none of the channels are receiving the data. I am stuck in this issue.

    Thank you.

  • In reply to Nitihin N:

    Nitihin,

    Does the UART Echo example in the product work for you? Can you confirm you are calling Board_initUART in your app where none of the UART instances are working.

    Todd
  • In reply to ToddMullanix:

    UART ECHO example did work, where it was echoing the characters that i was typing on my serial monitor.I am trying to implement the same concept,but instead of typing, it has to receive the character. I am calling Board_initUART inside my main function. 

  • In reply to Nitihin N:

    Can you attach a sample program with the problem and let me know which Launchpad you are using?

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.