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.

How to use System_printf() in cc2650 sensor tag? Do I need to enable the UART?

Other Parts Discussed in Thread: CC2650

Hello experts,

I'm trying to add debug logging with printf to the CC2650STK SensorTag default app and have followed instructions given here: e2e.ti.com/.../1778526

I didn't get any log output.

Then I tried with the uartecho_CC2650STK_TI_CC2650F128 default project, and I get the printf messages from that in the CCS console. I've tried to figure out what the difference is and have concluded that I need to add/initialize the UART.

In main.c of the SensorTag default app, I added:

#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <ti/drivers/UART.h>

...and changed the main function like this (just added the UART_init(); call, see below)

int main()
{
PIN_init(BoardGpioInitTable);

#ifndef POWER_SAVING
/* Set constraints for Standby 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 */
GAPRole_createTask();

/* Kick off application - Priority 1 */
SensorTag_createTask();
SensorTagTmp_createTask();
SensorTagHum_createTask();
SensorTagBar_createTask();

//added by me:
UART_init();

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

System_printf("Hello World :)");
System_flush();

return 0;
}


The problem is that I get this linker error:

undefined first referenced  
symbol in file  
—------- —------------—  
UART_init ./Startup/main.obj

error #10234-D: unresolved symbols remain
error #10010: errors encountered during linking; "SensorTag.out" not built

» Compilation failure
gmake: *** [SensorTag.out] Error 1
gmake: Target `all' not remade because of errors.

**** Build Finished ****

I'm I on the right path to get this working? What do I need to do to solve the problem?

Do I even need to add the UART initialization?

What about this line from appBLE.cfg, could this be reason I get no logs?

/* no logging - all compiled out */

BIOS.logsEnabled = false;

Your help will be appreciated, cheers,


Florian

  • Hi Flogo,

    Which version of TI-RTOS are you using?

    Are you trying to print on the UART terminal or on CCS console?

    If it's to print on UART terminal, then you would need to set-up UART. From your code, it looks like you are missing TI-RTOS board initialization functions: Board_initGeneral() and Board_initUART() in your main(). I would suggest looking at the UART echo example (specifically uartecho.c and uartecho.cfg) as an example to set up UART.

    If it's to print on CCS console, the System_printf() should be all you need. Looking through your code, I see that you are calling System functions after BIOS_start(). In TI-RTOS, no functions/statements after BIOS_start() in main() are executed as the context switches to a different Task. You can either call the System_printfs before BIOS_start() in main() or in a Task context.

    Hope this helps,
    Vikram
  • Hi Vikram, 

    thanks for your quick reply.

    The project came with the newest version of CCS (6.1.2) that is recommended for SensorTag development. It includes TI-RTOS like this "C:\ti\tirtos_simplelink_2_13_00_06\packages\ti\drivers", so I guess the version number is 2.13.

    I don't care for talking to a UART terminal, I just want to be able to see what's going on when I develop firmware. I guess the CCS console should be fine for that.

    I moved the System_printf and System_flush calls up, directly before BIOS_start and still don't see the messages.

    I read elsewhere that System_printf can be called from anywhere, but System_flush needs to be called from a task. Could you show me how to use the idle task for that?

    Looking forward to your reply, cheers,

    Flogo

  • Hi Flogo,

    Is CCS connected to the CC2650 SensorTag through Sensor Debugger DevPack? Are you using the BLE SDK or TI-RTOS SDK? If you are using TI-RTOS SDK, can you tell me the example that you are using?

    Vikram

  • Hi Vikram,

    Yes I'm using the debugger Devpack that I purchased for $15.

    The project is the same that comes pre-installed on the SensorTag, the one demonstrating all the sensors (except the microphone) that's compatible with the iPhone SensorTag app.

    Looking forward to your reply,

    Flogo
  • Hi Flogo,

    Can you run a TI-RTOS example on the sensor tag and check if you can see the print statements?

    I am unfamiliar with the out of box sensor example. Lets just make sure that TI-RTOS examples are working on your hardware. I can then move this thread to CC2650 device forums for experts familiar with sensors example answer your question.

    Vikram
  • Hey Vikram,

    I could see the output of the printf commands from the UART Echo example that came with the IDE. (Only those in CCS, the loopback with a terminal program didn't work yet).

    Flogo

  • Great! For UART terminal, please make sure the terminal program is set to the correct baudrate and other set-up parameters. The readme file in the example provides the set-up details.

    I will move this thread to the CC2650 device forum for experts familiar with Sensor Tag example to help you with your original question.

    Thanks,
    Vikram
  • Hi Flogo,

    The SensorTag uses the SysCallback provider (as opposed to SysMin that the UART echo one uses).

    For the example, the SysCallback functions are configured to be the defautls...which do nothing:

    I expect this was done to minimize footprint. You can use SysMin instead

    /* ================ System configuration ================ */
    var SysMin = xdc.useModule('xdc.runtime.SysMin');
    System.SupportProxy = SysMin;
    SysMin.bufSize = 512;

    And comment out the SysCallback references in the .cfg. Note: I shrunk the bufSize down to fit in the memory. Now the output should come to the CCS console when

    - System_flush is called

    - The program exits

    You can see the SysMin buffer in ROV also.

    Please note that CCS actually halts the target and reads to memory (CIO buffer) when the System_flush is called and the CIO buffer is full or a '\n' is written. This is generally not a good thing to do while doing real-time critical things. It works well for general debugging though.

    Todd

  • Thanks so much, Todd,

    Now I see the "hello world" from main.c.

    Additionally, I changed the file SensorTag_IO.c to add some debugging:

    In 

    void SensorTagIO_processCharChangeEvt(uint8_t paramID),

    I changed the final if/else branch like this:

    if (!!((ioValue & IO_DATA_BUZZER)))
     {
      Clock_start(buzzClockHandle);
      System_printf("Starting buzzer...");
      System_flush();
    }
    else
    {
      Clock_stop(buzzClockHandle);
      PIN_setOutputValue(hGpioPin, Board_BUZZER, Board_BUZZER_OFF);
      System_printf("Stopping buzzer...");
      System_flush();
    }

    The problem is now that my iPhone looses the connection immediately after I turn on the buzzer. But "Starting buzzer..." is still displayed.

    This probably has to do with the warning you gave. Is there a trick to make sure the buffer is only flushed when nothing important is happening?

    I appreciate your help, looking forward to your reply,

    Flogo

     

  • You can put a function into the Idle task that calls System_flush. It's not perfect since you may over-write the data before it is flushed, but minimizes the risk. The other option is to use SysCallback and send the data out the UART.

    Todd
  • Hi Vikram,

    I'd also be interested in getting the UART working.

    I'm on Windows 8.1 and I can't get it to work.

    In the UART Echo example, I modified the echo loop:

    /* Loop forever echoing */
    while (1) {
        UART_write(uart, echoPrompt, sizeof(echoPrompt));

        System_printf("while running...");
        System_flush();

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

    I know the loop is running because I see the output from System_printf a few times per second.

    I have tried with Tera Term (and three other serial port console programs) but none of them have worked, so now I think there is another problem somewhere.

    Tera Term shows me two ports:

    * XDS110 Class Auxiliary Data Port

    * XDS110 Class Application/User UART

    I selected the User UART and made sure the settings are precisely as given in the Readme file:

    Baud-rate: 9600
    Data bits: 8
    Stop bits: 1
    Parity: None
    Flow Control: None

    There is nothing displayed in the serial console after opening the connection.

    Do you have any tips for me? What Serial Console program are you using in your tests?

    Cheers,

    Florian

  • Why did you comment out the echo? Do you see the com ports in Device Manager?