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/CC3220SF-LAUNCHXL: Running Uart in parallel

Part Number: CC3220SF-LAUNCHXL

Tool/software: TI-RTOS

I am using aws sdk with tirtos. 

I have set up Uart1 for reading. How do I then run the the uart write in parallel with that? I tried making two processes and declaring the handler globally but doesn't seem to like that. I have read in a loop where it blocks until it gets a read. How would I do a write while that is going on?

  • Hi Jonathon,

    You should be able to read and write to the same UART driver, assuming that they are passed different buffers. (See the TI Drivers UART documentation in the CC3220 SDK at the Reading the Writing data section: docs\tidrivers\tidriversAPIs.html)

    What specific behavior are you seeing when you try using blocking read and write calls in different threads?

    Best regards,
    Sarah
  • it is more I do not know how to use them both. if I make uart handler global it doesn't work so I have to use in same process. if I am looping with a blocking read how do I write when I need to?

    the examples don't show that. they have monitoring and echo examples that get a read then do a write. but I want to write even if there was no read
  • here is basically my code...

    UART_Handle uart_inlo;
    //UART_Params uartParams;

    //void uart_inlo_init(void){
    // UART_Params_init(&uartParams);
    // uartParams.baudRate = 115200;
    // uartParams.readMode = UART_MODE_BLOCKING;// UART_MODE_CALLBACK;
    // 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 = UART_WAIT_FOREVER;
    // // uartParams.readCallback = UartReadCallback;
    //
    // uart_inlo = UART_open(Board_UART1, &uartParams);
    //
    //// if (!uart)
    //// {
    //// return false;
    //// }
    ////
    //// int ret = UART_read(uart, uartRxBuf, 2); //read 2 bytes
    //
    //// if (ret == UART_ERROR)
    //// {
    //// return false;
    //// }
    //
    // return true;
    //}

    /*
    * ======== mainThread ========
    */
    void *Uart(void *arg0)
    {
    // UART_Handle uart_inlo;
    UART_Params uartParams;

    /* Initialize and open UART */
    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.readMode = UART_MODE_BLOCKING;
    uartParams.baudRate = 115200;

    uart_inlo = UART_open(Board_UART1, (UART_Params *) &uartParams);

    // uart_inlo_init();

    while (1)
    {

    UART_read(uart_inlo, &ip,9)

    }

    }

    void write_function(write_buf, len){

    UART_write(uart_inlo, &write_buf,len)

    }

    I cleaned it up a lot so you can see but basically I have the read in a loop because I am reading most of the time. Very few writes.

    Now I am trying to add the write and I can not declare my handler globally. It can only be declared it seems in the main thread. 

    I have seen other people on this forum using it globally. Is there something I need to to to be able to allow that?

  • Hi Jonathon,

    I'm confused why you cannot define your UART handle globally. If I can read this accurately with the comments, it looks like you are doing that correctly.
    Are you getting a compile error? Are you seeing an error when you call UART_read and _write? If so, please capture the return value in a debug session so we can see the error code.

    Best regards,
    Sarah
  • Hi Jonathon,

    I haven't heard back, so I'm hoping you were able to resolve your issue. If not, you can post a reply or create a new thread and link to this one if it has locked already.

    Best regards,
    Sarah
  • it actually seems the uart_read doesn't block like I thought it did. so the global declaration still doesn't work but I got it to work.