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.

CCS/LAUNCHXL-CC2650: UART code not working

Part Number: LAUNCHXL-CC2650
Other Parts Discussed in Thread: CC2650

Tool/software: Code Composer Studio

Hi!

I am using CC2650 launchpad with CCS and I am trying to send out received advdata(of beacons) to my PC through UART. 

I have made changes in the code in the simple_peripheral_observer.c file and the main.c file. Here is my code - 

Includes - 

#include <string.h>
#include<stdio.h>

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Swi.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Queue.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>

#include "hci_tl.h"
#include "gatt.h"
#include "linkdb.h"
#include "gapgattserver.h"
#include "gattservapp.h"
#include "devinfoservice.h"
#include "simple_gatt_profile.h"

#if defined(FEATURE_OAD) || defined(IMAGE_INVALIDATE)
#include "oad_target.h"
#include "oad.h"
#endif //FEATURE_OAD || IMAGE_INVALIDATE

#include "peripheral_observer.h"
#include "gapbondmgr.h"

#include "osal_snv.h"
#include "icall_apimsg.h"

#include "util.h"

#ifdef USE_RCOSC
#include "rcosc_calibration.h"
#endif //USE_RCOSC

#include <ti/mw/display/Display.h>
#include "board_key.h"
#include "board.h"

#include "simple_peripheral_observer.h"

#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>
#include <ti/drivers/PIN.h>
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"

#include <stdint.h>

#include <xdc/std.h>
#include <xdc/runtime/System.h>

#include "ICall.h"
#include "hal_types.h"

Function declaration in main.c - 

extern void SimpleUART_createTask(void);

Function declaration in simple_peripheral_observer.c - 

static void SimpleUART_taskFxn(UArg a0, UArg a1);

Function call from main.c - 

 SimpleUART_createTask();

Function body in simple_peripheral_observer.c - 

void SimpleUART_createTask(void)
{ 
Task_Params taskParams;
//Board_initGeneral();
//Board_initUART();

Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)SimpleUART_taskFxn, &taskParams, NULL);
}

Function body in simple_peripheral_observer.c - 

static void SimpleUART_taskFxn(UArg a0, UArg a1)
{  
    UART_Handle uart;
    UART_Params uartParams;

    //UART_init();
    const char hello[] = "UART is working.\n";

    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)
    {
        fflush(stdout);
        printf("UART did not open.");
    }
    int number;
    number = UART_write(uart, hello, sizeof(hello));
    fflush(stdout);
    printf("UART wrote %d bytes.\n", number);

}

The code builds perfectly, without any errors. However, I get the warning -

"Invalid project path: Duplicate path entries found (/simple_peripheral_observer_cc2650lp_app [Include path] isSystemInclude:true includePath:C:/ti/tirtos_cc13xx_cc26xx_2_20_01_08/products/tidrivers_cc13xx_cc26xx_2_20_01_10/packages), path: [/simple_peripheral_observer_cc2650lp_app]"

The code starts to debug, however the UART port is not opening. Is my code wrong? Or is there something I need to change in any of the header files? Or is my code not working due to the warning? 

Please suggest me with a solution. Thanks in advance.

  • Hi Ankita,

    Other than the UART not working, does the Simple Peripheral Observer project still behave as expected? Can you see advertisements?

    I don't think the code is not working because of the warning. Are you using UART for anything else in your application?
  • If UART is not opening, instead of

        if (uart == NULL)

        {
            fflush(stdout);
            printf("UART did not open.");
        }
    Try

    while(hUART == NULL)
    {
       //nop
    }

  • Hi,

    I first tried 'while(hUART == NULL)', this gave me an error -  'hUART is undefined'

    So I tried 'while(uart == NULL)' with the printf statement, and saw "UART did not open" printed continuously in the console window.

    How do I get the UART to open?

    Thanks in advance.

  • Hey,

    I'm using UART to send AdvData to PC. Later, I will be using UART to send AdvData to another MCU.

    I have disabled the advertising part of the peripheral code, so as to configure my CC2650 as just observer, so I cannot find any beacons on my ios app.

    Apart from this, I do not know if the observer is receiving beacons. Can you suggest me a way to do that?

    Thanks in advance