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_open() always returns NULL

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

Tool/software: Code Composer Studio

Hey,

(second post about same issue as i did not receive any replies after the first reply)

I am working with the Simple Peripheral Observer example using the CC2650 Launchpad, BLE Stack v2.2, and TI RTOS v2.20.

I want to establish UART communication between CC2650 and my PC.

I have copied the UartEcho code. It builds without errors but no UART_handle is returned when UART_Open(...) is called. 

'UART not opened' is continuously printed in the Console window. 

Code - 

/*******************************************************************************
 * INCLUDES
 */
#include<stdio.h>
#include <xdc/runtime/Error.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>

#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>

#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>
//#include <tirtos_cc13xx_cc26xx_2_20_01_08\products\tidrivers_cc13xx_cc26xx_2_20_01_10\packages\>
#include <ti/drivers/PIN.h>

#include "icall.h"
#include "hal_assert.h"
#include "bcomdef.h"
#include "peripheral_observer.h"
#include "simple_peripheral_observer.h"

/* Header files required to enable instruction fetch cache */
#include <inc/hw_memmap.h>
#include "inc/hw_ints.h"
#include <driverlib/vims.h>

#ifndef USE_DEFAULT_USER_CFG

#include "ble_user_config.h"

// BLE user defined configuration
bleUserCfg_t user0Cfg = BLE_USER_CFG;

#endif // USE_DEFAULT_USER_CFG

#include <ti/mw/display/Display.h>

#include <stdint.h>

#include "Board.h"
#include "hal_types.h"

#include <string.h>

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

static char uartTaskStack[512];
static Task_Struct uartTask;

static void uartTaskFxn(UArg a0, UArg a1)
{

    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);

    while (uart == NULL) {
        //System_abort("Error opening the UART");
        fflush(stdout);
        printf("UART did not open\n");
    }

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

    /* Task Loop forever echoing */
    while (1) {
        UART_read(uart, &input, 1);

        UART_write(uart, &input, 1);
        // Put out a second time, so easy to verify on scope
        UART_write(uart, &input, 1);
    }
}

int main()
{
  /* Register Application callback to trap asserts raised in the Stack */
  RegisterAssertCback(AssertHandler);

  PIN_init(BoardGpioInitTable);

  /* Initialize ICall module */
  ICall_init();

  /* Start tasks of external images - Priority 5 */
  ICall_createRemoteTasks();

  /* Kick off profile - Priority 3 */
  GAPRole_createTask();

  SimpleBLEPeripheral_createTask();

    Task_Params tp;
UART_init();
Task_Params_init(&tp);
tp.stack = uartTaskStack;
tp.stackSize = sizeof(uartTaskStack);
tp.priority = 1;
Task_construct(&uartTask, uartTaskFxn, &tp, NULL);

/* enable interrupts and start SYS/BIOS */
BIOS_start();
return(0);

}

 

  • Hi Ankita,

    The most likely reason why your UART didn't open is because there may be another resource already using it (for example the display driver any be opening the port)

    For example, by default simple_peripehral will attempt to use the display driver (atleast in newer examples) and it may open the UART port.

    You can verify this by looking at the simple_peripehral code and verifying it's not using anything UART related.

    It's also possible that the board file doesn't set up the Board_UART0 correctly - make sure they are valid pins.

    Regards,
    Rebel