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.

CC2650 UART printf to terminal

Other Parts Discussed in Thread: CC2650STK

I followed the example on  and was unsuccessful in my attempt to get System_printf to appear on my terminal (putty). 

This is my code below from the main.c file:

/**
  @file  main.c
  @brief main entry of the BLE stack sample application.

  <!--
  Copyright 2013 - 2015 Texas Instruments Incorporated. All rights reserved.

  IMPORTANT: Your use of this Software is limited to those specific rights
  granted under the terms of a software license agreement between the user
  who downloaded the software, his/her employer (which must be your employer)
  and Texas Instruments Incorporated (the "License").  You may not use this
  Software unless you agree to abide by the terms of the License. The License
  limits your use, and you acknowledge, that the Software may not be modified,
  copied or distributed unless embedded on a Texas Instruments microcontroller
  or used solely and exclusively in conjunction with a Texas Instruments radio
  frequency transceiver, which is integrated into your product.  Other than for
  the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  works of, modify, distribute, perform, display or sell this Software and/or
  its documentation for any purpose.

  YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  PROVIDED ``AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

  Should you have any questions regarding your right to use this Software,
  contact Texas Instruments Incorporated at www.TI.com.
  -->
*/
#include "uart_printf.h"
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>

#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <ti/sysbios/BIOS.h>

#include "ICall.h"
#include "observer.h"
#include "simpleBLEObserver.h"

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

#ifndef USE_DEFAULT_USER_CFG

#include "bleUserConfig.h"

// BLE user defined configuration
bleUserCfg_t user0Cfg = BLE_USER_CFG;

#endif // USE_DEFAULT_USER_CFG

/**
 * Exception handler
 */
void exceptionHandler()
{
    volatile char i = 1;
    while(i);
}

/*
 *  ======== main ========
 */
int main()
{
  PIN_init(BoardGpioInitTable);

  // Enable System_printf(..) UART output
    UART_Params uartParams;
    UART_Params_init(&uartParams);
    uartParams.baudRate = 115200;
    UartPrintf_init(UART_open(Board_UART, &uartParams));


#ifndef POWER_SAVING
    /* Set constraints for Standby, powerdown and idle mode */
    Power_setConstraint(Power_SB_DISALLOW);
    Power_setConstraint(Power_IDLE_PD_DISALLOW);
#endif //POWER_SAVING

    /* Initialize ICall module */
    ICall_init();

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

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

    /* Kick off application - Priority 1 */
    SimpleBLEObserver_createTask();

    /* enable interrupts and start SYS/BIOS */
    BIOS_start();
    
    System_printf("Hello, universe!\r\n");

    return 0;
}

/**
 * Error handled to be hooked into TI-RTOS
 */
Void smallErrorHook(Error_Block *eb)
{
  for (;;);
}

/**
 * HAL assert handler required by OSAL memory module.
 */
void halAssertHandler(void)
{
  for (;;);
}

I have also changed the appBLE.cfg:
var ROM = xdc.useModule('ti.sysbios.rom.ROM');
ROM.romName = ROM.CC2650;

var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Types = xdc.useModule('xdc.runtime.Types');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Main = xdc.useModule('xdc.runtime.Main');
var Memory = xdc.useModule('xdc.runtime.Memory')
var SysCallback = xdc.useModule('xdc.runtime.SysCallback');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var Reset = xdc.useModule('xdc.runtime.Reset');
var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Task = xdc.useModule('ti.sysbios.knl.Task');

var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
var M3Hwi = xdc.useModule('ti.sysbios.family.arm.m3.Hwi');
var Power = xdc.useModule('ti.sysbios.family.arm.cc26xx.Power');

/* Enable idle task (default). */
Task.enableIdleTask = true;

/* Idle CPU when threads blocked waiting for an interrupt */
Power.idle = true;
Power.policyFunc = Power.standbyPolicy;
Power.calibrateRCOSC = false;

/* compile out all Assert's */
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;

/* Don't load string names of modules on the target */
Defaults.common$.namedModule = false;

/* Allow Mod_create() and Mod_construct() but not delete() or destruct() */
Defaults.common$.memoryPolicy = Types.CREATE_POLICY;

/* Don't load diagnostic/descriptive text strings on the target */
Text.isLoaded = false;

/* Use the minimal user-supplied callback provider */
System.SupportProxy = SysCallback;
/* no exit handlers needed */
System.maxAtexitHandlers = 0;

/* main() and Hwi, Swi stack size */
Program.stack = 1024;
/* no command-line arguments main(argc, argv) needed */
Program.argSize = 0;

/* build a custom, optimized version of SYS/BIOS */
BIOS.libType = BIOS.LibType_Custom;

/* no logging - all compiled out */
BIOS.logsEnabled = false;

/* disable Asserts in SYS/BIOS code */
BIOS.assertsEnabled = false;

/* Reduce number of Task priority levels to save RAM */
Task.numPriorities = 6;

/* Set the default Task stack size - used if one is not specified */
Task.defaultStackSize = 512;

/* Don't check stacks for overflow - saves cycles (and power) and Flash */
Task.checkStackFlag = false;

/* Disable exception handling to save Flash - undo during active development */
M3Hwi.enableException = true;
M3Hwi.excHandlerFunc = null; /* null = default while loop function. Use e.g. "&myFxn" to use your own function. */
M3Hwi.nvicCCR.UNALIGN_TRP = 0;
M3Hwi.nvicCCR.DIV_0_TRP = 0;

/* Don't check for interrupt stack overflow during Idle loop */
Hwi.checkStackFlag = false;

/* Minimize Flash and RAM usage of Error module */
Error.raiseHook = null; /* null = default while loop function. Use e.g. "&myFxn" to your own handler function. */
Error.maxDepth = 2;

/* Set the default CPU frequency */
BIOS.cpuFreq.lo = 48000000;

/* Put reset vector at start of Flash */
M3Hwi.resetVectorAddress  = 0x0;

/* Put interrupt vector at start of RAM so interrupts can be configured at runtime */
M3Hwi.vectorTableAddress  = 0x20000000;

/* CC2650 has 50 interrupts */
M3Hwi.NUM_INTERRUPTS = 50;

/* Create a small heap */
BIOS.heapSize = 1668;

var Swi = xdc.useModule('ti.sysbios.knl.Swi');
Swi.numPriorities = 6;
BIOS.swiEnabled = true;

BIOS.includeXdcRuntime = true;

/* Tasks cannot pend based on priority */
Semaphore.supportsPriority = false;

/* Change default error function -- just spin */
Error.policyFxn = Error.policySpin;

/* true:  Allow runtime creation of e.g. semaphores
 * false: Compile out reference to Memory in BIOS */
BIOS.runtimeCreatesEnabled = true;

/* Abort and exit functions -- just spin */
System.abortFxn = System.abortSpin;
System.exitFxn = System.exitSpin;

/* CC26xx Boot module */
var Boot = xdc.useModule('ti.sysbios.family.arm.cc26xx.Boot');
Boot.driverlibVersion = 2;
Boot.customerConfig = false;

/* 10 us tick period */
Clock.tickPeriod = 10;

/* Uart printout */
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
Idle.addFunc('&uartPrintf_flush');
SysCallback.putchFxn = "&uartPrintf_putch";

I am currently using BLE stack 2.1.1 because the UART implementation linked on the website was not possible on the latest BLE stack 2.2. I am also using the TI RTOS that came with the BLE stack, which is TI RTOS 2.13.

Thanks for reading the post, any help on what to do from here will be appreciated.



  • Hi,

    I think that you're missing this in your cfg file.

    /* Enable the TI-RTOS UART drivers */
    TIRTOS.useUART = true;

    Regards,

    Michel

  • Hey Michel, I have added that and the printf output is still not visible on my putty terminal.

    Putty settings:

    I am using a CC2650STK with a XDS110 rev 1.3. I think it might be a issue with the pins listed in my Board.h file:

    /*
     * Copyright (c) 2015, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    /** ============================================================================
     *  @file       Board.h
     *
     *  @brief      CC2650SENSORTAG Board Specific header file.
     *
     *  NB! This is the board file for PCB version 1.2
     *
     *  The CC2650 header file should be included in an application as follows:
     *  @code
     *  #include <Board.h>
     *  @endcode
     *
     *  ============================================================================
     */
    #ifndef __BOARD_H__
    #define __BOARD_H__
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    /** ============================================================================
     *  Includes
     *  ==========================================================================*/
    #include <ti/drivers/PIN.h>
    #include <driverlib/ioc.h>
    
    /** ============================================================================
     *  Externs
     *  ==========================================================================*/
    extern PIN_Config BoardGpioInitTable[];
    
    /** ============================================================================
     *  Defines
     *  ==========================================================================*/
    
    /* Symbol by generic Board.c to include the correct PCB  specific Board.c */
    #define CC2650ST_0120
    
    /* Identify as SensorTag */
    #define CC2650ST_7ID
    
    /* This PCB version supports magnetometer */
    #define FEATURE_MAGNETOMETER
    
    /* External flash manufacturer and device ID */
    #define EXT_FLASH_MAN_ID            0xEF
    #define EXT_FLASH_DEV_ID            0x12
    
    /* Mapping of pins to board signals using general board aliases
     *      <board signal alias>                <pin mapping>
     */
    
    /* Discrete outputs */
    #define Board_LED1                  IOID_10
    #define Board_LED2                  IOID_15
    #define Board_BUZZER                IOID_21
    #define Board_LED_ON                1
    #define Board_LED_OFF               0
    #define Board_BUZZER_ON             1
    #define Board_BUZZER_OFF            0
    
    /* Discrete inputs */
    #define Board_KEY_LEFT              IOID_0
    #define Board_KEY_RIGHT             IOID_4
    #define Board_RELAY                 IOID_3
    
    /* Sensor outputs */
    #define Board_MPU_INT               IOID_7
    #define Board_TMP_RDY               IOID_1
    
    /* I2C */
    #define Board_I2C0_SDA0             IOID_5
    #define Board_I2C0_SCL0             IOID_6
    #define Board_I2C0_SDA1             IOID_8
    #define Board_I2C0_SCL1             IOID_9
    
    /* SPI */
    #define Board_SPI_FLASH_CS          IOID_14
    #define Board_SPI_DEVPK_CS          IOID_20
    #define Board_FLASH_CS_ON           0
    #define Board_FLASH_CS_OFF          1
    
    #define Board_SPI0_MISO             IOID_18
    #define Board_SPI0_MOSI             IOID_19
    #define Board_SPI0_CLK              IOID_17
    
    /* UART (when connected to SRF06EB) */
    #define Board_EB_UART_TX            IOID_16
    #define Board_EB_UART_RX            IOID_17
    
    /* DevPack */
    #define Board_AUDIOFS_TDO           IOID_16
    #define Board_AUDIODO               IOID_22
    #define Board_DP2                   IOID_23
    #define Board_DP1                   IOID_24
    #define Board_DP0                   IOID_25
    #define Board_DP3                   IOID_27
    #define Board_DP4_UARTRX            IOID_28
    #define Board_DP5_UARTTX            IOID_29
    #define Board_DEVPK_ID              IOID_30
    
    /* Power control */
    #define Board_MPU_POWER             IOID_12
    #define Board_MPU_POWER_ON          1
    #define Board_MPU_POWER_OFF         0
    
    /* Audio */
    #define Board_MIC_POWER             IOID_13
    #define Board_MIC_POWER_ON          1
    #define Board_MIC_POWER_OFF         0
    #define Board_AUDIO_DI              IOID_2
    #define Board_AUDIO_CLK             IOID_11
    
    
    /** ============================================================================
     *  Instance identifiers
     *  ==========================================================================*/
    /* Generic I2C instance identifiers */
    #define Board_I2C                   CC2650_I2C0
    /* Generic SPI instance identifiers */
    #define Board_SPI0                  CC2650_SPI0
    /* Generic UART instance identifiers */
    #define Board_UART                  CC2650_UART0
    
    
    /** ============================================================================
     *  Number of peripherals and their names
     *  ==========================================================================*/
    
    /*!
     *  @def    CC2650_I2CName
     *  @brief  Enum of I2C names on the CC2650 dev board
     */
    typedef enum CC2650_I2CName {
        CC2650_I2C0 = 0,
        CC2650_I2CCOUNT
    } CC2650_I2CName;
    
    /*!
     *  @def    CC2650_SPIName
     *  @brief  Enum of SPI names on the CC2650 dev board
     */
    typedef enum CC2650_SPIName {
        CC2650_SPI0 = 0,
        CC2650_SPICOUNT
    } CC2650_SPIName;
    
    /*!
     *  @def    CC2650_UARTName
     *  @brief  Enum of UARTs on the CC2650 dev board
     */
    typedef enum CC2650_UARTName {
        CC2650_UART0 = 0,
        CC2650_UARTCOUNT
    } CC2650_UARTName;
    
    /*!
     *  @def    CC2650_UdmaName
     *  @brief  Enum of DMA buffers
     */
    typedef enum CC2650_UdmaName {
        CC2650_UDMA0 = 0,
        CC2650_UDMACOUNT
    } CC2650_UdmaName;
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif /* __BOARD_H__ */
    

    Let me know if more code snippets are needed.

  • Thanks Michel, not sure what was wrong but i used the latest compiler TI 16.6 STS and updated CCS.