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/LAUNCHXL-CC2640R2: Understanding the UART_read() command

Part Number: LAUNCHXL-CC2640R2

Tool/software: TI-RTOS

Hi,

I'm in some trouble with receiving over UART. In my scenario, i want to send a command (as a master) and then read the answer from a LIN-Bus slave node.

Everything works fine, until reading back the answer from the LIN slave node.

But if i use two Launchpads sending with the first one only the request and if i read back the answer with a second one everything works fine.

    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readTimeout = 20 * 1000 / Clock_tickPeriod;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 19200;

        LINHeader[1] = calcPID(0x22);
        sendBreak();
        UART_write(uart, &LINHeader, 2); //sending request
        UART_read(uart, &FrameBuffer, 8); //reading answer

How do i have to configure the UART interface to swtich to reading after sending the Header? I think i have to use UART_readPolling(), but this command is not supported according to the driver documentation.

regards

Maximilian

  • Hello Maximilian,

    Did you take a logic analyzer capture of the UART pins (behind the LIN bus driver) to confirm the expected waveform is being sent back? UART_read is blocking so it should wait until the specified readTimeout occurs. Did you check for a timeout?

    Best wishes
  • Hello,

    Yes, i checked this. The delay is 120 us @ 19200 Baud.

    The weird thing is, if i add a delay with 110 us all bytes are read expecting the first one.

    Should i better use the callback function?

    Best wishes
  • I'm not sure what the exact problem is when using the LIN slave mode. Are you not getting the data? Are you missing data? Is the number of bytes off? Can you check the return value of UART_read and see how much data you actually got?

    Tom

  • I'm getting the complete frame but without the first byte. If i run the code without the delay of 110 us, nothing is recieved. In this case, the code runs only if i add a uartParams.readTimeout.

    The delay is between my write command of the LIN PID and uart_read().

    The return value is 7,but the frame contains 8 bytes.