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.

UART_read() is not working

Other Parts Discussed in Thread: TM4C1294NCPDT, CC2650

Hi all,

MCU: Tiva C TM4C1294NCPDT

IDE: CCS V6.0.1

I have 4-tasks to read UART data(for com0,com1,com2 and com RS485). I created a buffer array with size 256.

I am using UART_read function

ret = UART_read(uart_handle, *txbuffer, 256);

my com0 is working fine, meaning that UART_read and UART_write functions are working. But the same code when i write for com1, com2,com RS485(changing port address). UART_read is not working....

I am expecting any data put on the uart_handle line will be read by this task. However, it does not do what I expect it.

How can I read any data as long as uart2 receives them?

  • Hi Jeetesh,

    Just to make sure I understand you correctly, you have 4 tasks each of which open an separate UART peripheral? Are you checking the return value from UART_open() to make sure they are opening correctly? What modes did you open the UART drivers in Blocking or Callback?

    Regards,
    -- Emmanuel
  • Hi Emmanuel,


    Yes i have 4 tasks for separate UART Peripherals and i checked the return value from UART_open() which is giving different value for each task...and i am using Callback mode....


    UART_open() is happening in every task,.. UART_write() is also working means that it is writing to hyper-terminal but UART_read() is not reading from Hyper-terminal.(only working for com0 and not for all other three tasks ). When i debugging then i know that UART_read() is not happening.(I am using same code changing with Com port number(address)).

    Regards

    jeetesh

  • Hi Jeetesh,

    Sorry for the delayed response.

    What return mode and data mode are you using (UART_RETURN_FULL or UART_RETURN_NEWLINE, UART_DATA_BINARY or UART_DATA_TEXT)? Can you provide a code snip?

    Regards,
    -- Emmanuel
  • Hi Emmanuel,


    I am using return mode as UART_RETURN_FULL and data mode as UART_DATA BINARY. But problem was in the windows Hyper-terminal.Actually Hyper-terminal was not releasing the data.  Moment when I disconnect the Hyper-terminal, data is flushed out. When i try with Brays Terminal, the problem gets solved.

    And Thanks a lot  for giving response.


    Regards

    Jeetesh


     

  • Hiii Jeetesh/Emmanuel

    I am working on uart communication between 2 SmartRF06 (CC2650) and i have connected RX to TX and TX to RX and GND to GND these r my hardware connections and i am developing my code in CCS IDE and my code is as fallow, but am unable to neither send or receive data some one please help me to solve this problem

    static PIN_Handle pinHandle;

    static PIN_State ModbusState;
    char taskStack[TASK_STACK_SIZE];
    Task_Struct taskStruct;
    UART_Handle hUART;
    BUFTYPE txBuf[2] = "AT";
    BUFTYPE rxBuf[2];
    uint16 val=0;

    UART_Params params;

    Semaphore_Struct semm;
    Semaphore_Handle hSem;

    static void uartRxCb(UART_Handle handle, void *buf, size_t count)

    {
    Semaphore_post(hSem);
    }

    void SimpleBLECentral_createTask(void)

    {
    Task_Params params;
    // Configure task
    Task_Params_init(&params);
    params.stack = sbcTaskStack;
    params.stackSize = SBC_TASK_STACK_SIZE;
    params.priority = SBC_TASK_PRIORITY;

    Task_construct(&taskStruct, SimpleBLECentral_taskFxn, &params, NULL);
    }

    static void SimpleBLECentral_taskFxn(UArg a0, UArg a1)

    {
    // Initialize application
    SimpleBLECentral_init();

    pinHandle = PIN_open(&ModbusState, BoardGpioInitTable);
    PIN_setOutputValue(pinHandle, PIN_ID(Board_UART_TX), 1);
    PIN_setOutputValue(pinHandle, PIN_ID(Board_UART_RX), 1);

    UART_Params_init(&params);
    params.readMode = UART_MODE_CALLBACK;
    params.writeMode = UART_MODE_BLOCKING;
    params.writeDataMode = UART_DATA_BINARY;
    params.readDataMode = UART_DATA_BINARY;
    params.readCallback = uartRxCb;
    params.readEcho = UART_ECHO_OFF;
    params.dataLength = UART_LEN_8;
    params.stopBits = UART_STOP_ONE;
    params.baudRate = 115200;

    hUART = UART_open(CC2650_UART0, &params);

    Semaphore_Params sParams;
    Semaphore_Params_init(&sParams);
    sParams.mode = Semaphore_Mode_BINARY;

    Semaphore_construct(&semm, 0, &sParams);
    hSem = Semaphore_handle(&semm);

    for(val=0;val<1000;val++)
    {
    UART_write(hUART, txBuf, sizeof(txBuf));
    LCD_WRITE_STRING("Message OK", LCD_PAGE4);
    UART_read(hUART, &rxBuf, sizeof(rxBuf));
    // UART_write(hUART, &rxBuf, sizeof(rxBuf));
    }

    if((strstr(rxBuf,"OK")) || (strstr(rxBuf,"ok")))
    {
    System_printf("AT : OK");
    LCD_WRITE_STRING("Done", LCD_PAGE4);
    }
    else
    {
    System_printf("Error..,");
    LCD_WRITE_STRING("Error", LCD_PAGE5);
    }

    but i am unable to receive at rxBuf so please let me knoe if any changes to be made in this code

    Thank You
  • Hi Martin,

    This thread has been closed. If this is still a problem, can you start a new thread ?

    Thanks,
    Ashish
  • Hii Ashish Kapania 

    could u please explain me properly abt which thread your talking 

    thank u 

  • Hi Martin,

    I was referring to this forum post thread. Can you create a new thread and post your question there ?

    Best,
    Ashish