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/CC2650: LaunchPad CC2650, can't read from UART!

Part Number: CC2650

Tool/software: TI-RTOS

Okay, so I've done a lot of testing and I'm able to see output of a GPS I'm connecting to via UART. When I have the GPS TX-> CC2650 TX I get the following output on the terminal:

This verifies that my GPS is sending correct data. I've written the following code in hopes that I could get something in my rxBuffer, but nothing is getting received. I switched my connection from GPS TX-> CC2650 RX pin, and I'm still not seeing data coming in. It just prints garbage and I'm not sure why nothing is coming in. This is what it looks like: 

I believe that I set up my code correctly. 

Any direction this would be very appreciated. Thanks.

  • Is the baudrate correct?
  • Yes. The GPS baudrate is 9600.
  • If you connect CC2650 to your PC and use terminal tool such as teraterm to input something into UART, does your UART code work?
  • NO idea how to use that software... Haven't heard about it or I can't find a reasonable way to download it.
  • You don't have to use teraterm. You can use any terminal tool like hypertermimal in Windows system.

  • Okay I'm using putty. How can I input something in a terminal?
  • You can type some characters into Putty to send them to assigned COM port.
  • Oh my guess is that they're sent, but it's not echo'd back. Okay well I tried that, I'm still seeing nothing going in my buffer.
  • If you test UART echo example at dev.ti.com/.../ , does it work?
  • Thanks for taking the time to work with me. I've been working on this all day...
    The ECHO example seems to be working. This will help knowing that it works. I'm still unsure of what to do, but hopefully I figure it out.
  • Hi, can you post the code that you used to obain GPS co-ordinates? 

    I can get it on Arduino, struggling to get it on CC2650. 

    Thanks

  • hi i am also facing the same issue did you find the solution. if yes please share the solution. Thank you
  • You can't use the UART_readPolling function as this is not supported by the CC chip family. If you check the return value of the function you will see that it returns with an error status.

    This is why the UART echo example use UART_read and not UART_readPolling. Try using UART_read and see if you are able to receive the data you expect.
  • Sir i am reading the GPS value using UART_read like following

    static unsigned char rxBuffer[20];
    static unsigned char ret;
    /*
    * Application LED pin configuration table:
    * - All LEDs board LEDs are off.
    */
    PIN_Config ledPinTable[] = {
    Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
    };

    /*
    * ======== echoFxn ========
    * Task for this function is created statically. See the project's .cfg file.
    */
    Void echoFxn(UArg arg0, UArg arg1)
    {

    char input;
    UART_Handle uart;
    UART_Params uartParams;
    const char echoPrompt[] = "\fEchoing characters:\r\n";



    /* 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 = 9600;
    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
    System_abort("Error opening the UART");
    }
    else{
    System_printf("UART communication done");
    }



    ret = UART_read(uart, rxBuffer, sizeof(rxBuffer));
    System_printf("The UART read %d bytes\n", rxBuffer);



    // UART_write(uart, echoPrompt, sizeof(echoPrompt));

    /* Loop forever echoing */
    while (1) {
    // ret = UART_read(uart, rxBuffer, sizeof(rxBuffer));
    UART_read(uart, &input, 1);
    //System_printf("The UART read %d bytes\n", rxBuffer);

    UART_write(uart, &input, 1);
    }
    }


    /*
    * ======== main ========
    */
    int main(void)
    {
    PIN_Handle ledPinHandle;
    Task_Params taskParams;

    /* Call board init functions */
    Board_initGeneral();
    Board_initUART();

    /* Construct BIOS objects */
    Task_Params_init(&taskParams);
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);

    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, ledPinTable);
    if(!ledPinHandle) {
    System_abort("Error initializing board LED pins\n");
    }

    PIN_setOutputValue(ledPinHandle, Board_LED1, 1);

    /* This example has logging and many other debug capabilities enabled */
    System_printf("This example does not attempt to minimize code or data "
    "footprint\n");
    System_printf("Data = %d \t ",rxBuffer);

    System_flush();

    System_printf("Starting the UART Echo example\nSystem provider is set to "
    "SysMin. Halt the target to view any SysMin contents in "
    "ROV.\n");
    /* SysMin will only print to the console when you call flush or exit */
    System_flush();

    /* Start BIOS */
    BIOS_start();

    return (0);
    }


    but i could not understand whether i am able to read the values or because i am not able to print the values. i tried to print the received values using System_printf in the echoFxn function but it is not printing. then i defined the variable as global and when i print it in main function using System_printf i get some value but not exactly sure it is received value or not. Because GPS data contain large number of data but i only get 568793 numbers only. So not able to find whether receiving data or not. please help me and guide me regarding this

  • I see you already have a thread regarding your problem here: e2e.ti.com/.../651586

    Please try to not hijack other E2E treads if it does not contribute to solving the initial problem. Mixing multiple problems in a single thread makes it hard to support in a reasonable manner. It also makes it hard for other members to find possible answers in the future when searching the forum for answers.
  • I've found the solution to the problem. I was able to properly use UART by removing the jumpers (TXD and RXD) that isolate the debugger from the MCU. Now that I removed those, I was able to use the MCU UART properly. I've added a top level design to show the connections below after my code. This is the code I used:

    #define TASKSTACKSIZE 768
    #define bSize 200
    #define packet 5
    #define time 6
    #define status 1
    #define LatDeg 2
    #define LongDeg 3
    #define DMM 6 //DMM degress and decimal minutes

    struct Buffer                                    // These are the buffers I've created and used to store data as I parse/iterate through the packet in my rxBuffer
    {
    unsigned char rxBuffer[bSize];
    char comparePacket[packet];
    char Time[time];
    char Status[status];
    char NS[status];
    char EW[status];

    char LatitudeDeg[LatDeg];
    char LatitudeDMM[DMM]; // DMM degrees and decimal minutes
    char LongitudeDeg[LongDeg];
    char LongitudeDMM[DMM];
    };

    Void GPS(UArg arg0, UArg arg1)
    {


    struct Buffer p;               //declare my struct in my main function
    bool done = false;
    bool comp = false;
    int i = 0;


    UART_Handle handle;
    UART_Params uartParams;
    Display_Params params;
    Display_Params_init(&params);
    params.lineClearMode = DISPLAY_CLEAR_BOTH;
    Display_Handle hDisplayLcd = Display_open(Display_Type_LCD, &params);


    /* Create a UART with data processing off. */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;                   //Not used, but Data is not processed mode
    uartParams.readDataMode = UART_DATA_BINARY;                   //Data is not processed mode
    uartParams.readReturnMode = UART_RETURN_FULL;              //Receive return mode / UART_RETURN_FULL unblock/callback when buffer is full
    uartParams.readEcho = UART_ECHO_OFF;                                //Echo received data back (false)
    uartParams.baudRate = 9600;                                                       //Set the baud rate of the GPS
    handle = UART_open(Board_UART0, &uartParams);                   //

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

    So I created a 200 byte rxBuffer (I pass in the struct Buffer in my parsing functions), and if you're UART is working properly then your buffer will return filled with data each time you do a UART_read(handle, p.rxBuffer, 200); function call. The adafruit GPS will populate your rxBuffer even when not locked on a satellite, it will send you packets with empty data. The GPS information is found in the GPS datasheet that you find on adafruit and it explains what baud rate you need to use, and other important information regarding the packets. I parsed through the buffer (each packet begins with a $) and did a string compare function that compared an array containing characters GPRMC to the packet headers I found in the rxBuffer. I hope this makes sense, feel free to ask questions if I didn't address your questions.

    bool comparePackets(struct Buffer * b, int k)         //Function used to compare GPRMC with packet headers found in rxBuffer. If true, then I continue parsing the data in rxBuffer...
    {
    char cmp[] = {'G','P','R','M','C'};
    int i = 0;

    for(i = 0; i < 5; i++)
    {
    k++;
    b->comparePacket[i] = b->rxBuffer[k];
    }
    int y;
    y = strncmp(cmp, b->comparePacket, 5);            //strncmp function comparing my cmp array and comparePacket buffer that contains a packet header... 
    if (y == 0)
    {
    return true;
    }
    return false;
    }

    This depiction isn't the CC2650, but it's just to show how the connections are set up. You connect the GPS Tx to the MCU Rx.

     

  • Thanks for the Solution. i will try this and inform you. Next time i will take care of not the mix-up the questions in a thread

  • Hi thanks but when i am reading the value using UART_read(uart, rxBuffer, 200); i am getting nothing. i am getting null value.
  • Did you remove the jumpers that isolate the debugger?

  • yes i have removed it, and applied your all instructions. but not getting

  • I wish there was a better way than just sending messages back and forth. Are you not getting a read from  Uart? are you debugging it and you aren't getting any values? Are you using the adafruit GPS? Take a picture of how you have it wired if you can. 

  • No i am not using Adrafruit GPS. i am using following GPS module.

    And i removed the Tx and Rx jumpers. And i have connected GPS Tx to Launchpad Rx and GPS Rx to LaunchPad Tx. and I am Printing the values using System_prinf. Thank you

  • Could I see your code? Also make sure the baudrate matches the baudrate that your gps device datasheets tell you. 

  • Hi sorry for the late response. I was busy on some other stuff. my code is for reading data is as following

    Void echoFxn(UArg arg0, UArg arg1)
    {
    int8_t abc[100], bcd[100];
    uint32_t RxBytes;
    UART_Handle uart;
    UART_Params uartParams;

    /* 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 = 9600;
    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
    System_abort("Error opening the UART");
    }
    else{
    System_printf("Uart open");
    }

    /* Loop forever echoing */
    while (1) {
    RxBytes= UART_read(uart, bcd, sizeof(bcd));
    memcpy(abc,bcd,RxBytes);
    UART_write(uart, abc, RxBytes);
    }
    }

    /*
    * ======== main ========
    */
    int main(void)
    {
    Task_Params taskParams;

    /* Call board init functions */
    Board_initGeneral();
    Board_initUART();

    /* Construct BIOS objects */
    Task_Params_init(&taskParams);
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);


    /* Start BIOS */
    BIOS_start();

    return (0);
    }

  • OK thanks for the support and reply now GPS is working for me. i am able to read the Data.