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.

MSP430F6779A: Unable to read all data from RX and the readTimeout of UART_read is not working.

Part Number: MSP430F6779A
Other Parts Discussed in Thread: MSP-TS430PEU128

Dear Experts,

I am testing UART on MSP430F6779A with board MSP-TS430PEU128.

My problem is on reading UART and cannot get all data from RX, here is the code how I to do that,

Void echoFxn(UArg arg0, UArg arg1)
{
    BYTE buffer[10];
    char input;
    int readSize = 1;

    UART_Handle uart;
    UART_Params uartParams;

    UART_Params_init(&uartParams);
    uartParams.readMode = UART_MODE_BLOCKING;
    uartParams.writeMode = UART_MODE_BLOCKING;
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.readTimeout = 1;
    uartParams.baudRate = 115200;
    uart = UART_open(1, &uartParams); /* P3.4,5 = USCI_A1 TXD/RXD */

    if (uart == NULL) {
        System_abort("Error opening the UART");
    }

    while (1) {
        UART_read(uart, &input, readSize);  //read 1 at once
        System_printf("%c\n", input); System_flush();
    }
}

I am using accessport tool to send data "1234567890", after run, I only got "1" and "0" which those are first and last characters. No mater what baudrate I set, only those two can be received.

Where I did wrong?

I also tried another way to read RX data which is read a block:

 

Void echoFxn(UArg arg0, UArg arg1)
{
    BYTE buffer[10];
    char input;
    int readSize = 1;

    UART_Handle uart;
    UART_Params uartParams;

    UART_Params_init(&uartParams);
    uartParams.readMode = UART_MODE_BLOCKING;
    uartParams.writeMode = UART_MODE_BLOCKING;
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.readTimeout = 1;
    uartParams.baudRate = 115200;
    uart = UART_open(1, &uartParams); //open PM_UCA1

    if (uart == NULL) {
        System_abort("Error opening the UART");
    }

    while (1) {
        UART_read(uart, &buffer, 10);  //read 10 at once
        System_printf("%s\n", (char *)buffer); System_flush();
    }
}

I use same tool to send data "1234567890" and got all data "1234567890" without missing. But here is the problem, if I just send data less than 10, then I'll never get returned from UART_read. Seems the readTimeout setting is not working, why is that happen?

Thanks in advanced.

  • Hi Patrick,

    In the first code of post, when you receive a byte from UART, you will print into console panel by the System_printf function, but at this time, the UART is still transmitting data. When the System_printf function is executed and read next data by UART_read, the intermediate data (23456789) has been sent, so it will be lost.

    For the second code of post, UART_read(uart, &buffer, 10) function will wait until receive 10 bytes data, you can look at the details of this function.

    You may be able to try to read the data using interrupts.

    Best Regards

    Johnson

  • Hi Johnson.

    Thanks for reply fast.

    About the 2'nd code, UART_read has to receive 10 bytes data no matter what the value of readTimeout? so what is this value doing exactly?

    Thanks.

    Patrick

  • Hi Patrick,

    This function is packaged on a register basis to allow the user to accurately read the data of the known number of bytes. But real-time and flexibility is poor, it is recommended that you use the register level or the driver library we provide. You can refer to this link:

    http://dev.ti.com/tirex/explore/node?node=AOusg7YgtR4yzFYky92.QA__IOGqZri__LATEST

    Best Regards

    Johnson

  • Hi Johnson,

    After struggled on TI-rtos drivers on F6779A, yes, I have to start to use the register level as you recommended.

    The link is very helpful, thanks.

    Patrick

**Attention** This is a public forum