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 Log Info

Other Parts Discussed in Thread: CC2650

Tool/software: TI-RTOS

Hi everyone

It's my firts post here, from Argentina.

The point is:

I have a CC2650 Launchpad developemt board. I want to use the I2C driver, with an Arduino Mega as a slave. But I can't get it. So, I decided that I want to debbug to find the problem.

Reading the TI-RTOS User Guide, I found:

"The instrumented I2C library contains Log_print() statements that help to debug I2C transfers. The I2C driver logs the following actions using the Log_print() APIs provided by SYS/BIOS:

• I2C object opened or closed.
• Data written or read in the interrupt handler.
• Transfer results.

Logging is controlled by the Diags_USER1 and Diags_USER2 masks. Diags_USER1 is for general
information and Diags_USER2 is for more detailed information. Diags_USER2 provides detailed logs
intended to help determine where a problem may lie in the I2C transaction. This level of diagnostics will
generate a significant amount of Log entries. Use this mask when granular transfer details are needed."

So, my question is:

How can I activate the Diags_USER2 logging? I didn't find any option in my .cfg file

Thanks

Here you have my code:

/*
 *  ======== empty_min.c ========
 */
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>

/* TI-RTOS Header files */
#include <ti/drivers/I2C.h>
#include <ti/drivers/i2c/I2CCC26XX.h>
#include <ti/drivers/PIN.h>
// #include <ti/drivers/SPI.h>
// #include <ti/drivers/UART.h>
// #include <ti/drivers/Watchdog.h>

/* Board Header files */
#include "Board.h"

#define TASKSTACKSIZE   512

Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];

/* Pin driver handle */
static PIN_Handle ledPinHandle;
static PIN_State ledPinState;

/*
 * Application LED pin configuration table:
 *   - All LEDs board LEDs are off.
 */
PIN_Config ledPinTable[] = {
    Board_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};

/* I2C */
I2C_Handle handle;
I2C_Params params;
I2C_Transaction i2cTrans;
uint8_t rxBuffer[32];            // Receive buffer
uint8_t txBuffer[32];            // Transmit buffer
bool transferDone = false;


Void Create_i2c(void){
	//Inicializamos
	I2C_init();
	// Configure I2C parameters.
	I2C_Params_init(&params);
	params.transferMode = I2C_MODE_BLOCKING;
	params.transferCallbackFxn = NULL;
	// Prepare data to send, send 0x00, 0x01, 0x02, ...0xFF, 0x00, 0x01...
	int i;
	for(i = 0; i < 32; i++)
	    txBuffer[i] = (uint8_t) i;
	//txBuffer[0] = 1;
	// Initialize master I2C transaction structure
	i2cTrans.writeCount   = 16;
	i2cTrans.writeBuf     = txBuffer;
	i2cTrans.readCount    = 0;
	i2cTrans.readBuf      = rxBuffer;
	i2cTrans.slaveAddress = 8;

	// Open I2C
	handle = I2C_open(Board_I2C, &params);
}


Void Transmit_dataFxn(UArg arg0, UArg arg1)
{
	Create_i2c();

    for(;;){
        // Do I2C transfer (in callback mode)
        if(I2C_transfer(handle, &i2cTrans)){PIN_setOutputValue(ledPinHandle, Board_LED0, 1);}
        else{PIN_setOutputValue(ledPinHandle, Board_LED1, 1);}
    }
}


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

    /* Call board init functions */
    Board_initGeneral();
    //Board_initI2C();
    // Board_initSPI();
    // Board_initUART();
    // Board_initWatchdog();

    /* Construct heartBeat Task  thread */
    Task_Params_init(&taskParams);
    taskParams.arg0 = 1000000 / Clock_tickPeriod;
    taskParams.stackSize = TASKSTACKSIZE;
    taskParams.stack = &task0Stack;
    Task_construct(&task0Struct, (Task_FuncPtr)Transmit_dataFxn, &taskParams, NULL);

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

    /* Start BIOS */
    BIOS_start();

    return (0);
}

  • Daniel,

    Modify your .cfg file to have to comment out driversConfig.LibType_NonInstrumented; and uncomment driversConfig.libType = driversConfig.LibType_Instrumented;

    Derrick

  • Thank you for your answer, Derrick!

    Yes, I've modified my .cfg file, and now works. There it is what I need to works:

    /* LOG CONFIGURATION  */
    var LoggingSetup = xdc.useModule('ti.uia.sysbios.LoggingSetup');
    //var LoggerStopMode = xdc.useModule('ti.uia.loggers.LoggerStopMode');
    
    // Remaining Modules
    var Diags = xdc.useModule('xdc.runtime.Diags');
    var Main = xdc.useModule('xdc.runtime.Main');
    var Reset = xdc.useModule('xdc.runtime.Reset');
    
    var UIAEvt = xdc.useModule('ti.uia.events.UIAEvt');
    var UIAErr = xdc.useModule('ti.uia.events.UIAErr');
    
    
    // Need Text loaded for formatting of Log_info/warning/error, but not for Log_print.
    Text.isLoaded = true;
    
    // Logging
    var Log = xdc.useModule('xdc.runtime.Log');
    
    // Override error output color with ANSI codes, and use shorter (file.c:line) format.
    Log.L_error =  {
        mask: Diags.STATUS,
        level: Diags.ERROR,
        msg: "\x1b[31;1mERROR:\x1b[0m (%s:%d) %$S"
    };
    
    Log.L_info = {
        mask: Diags.INFO,
        msg: "\x1b[32;1mINFO:\x1b[0m (%s:%d) %$S"
    };
    
    Log.L_warning = {
        mask: Diags.STATUS,
        level: Diags.WARNING,
        msg: "\x1b[33;1mWARNING:\x1b[0m (%s:%d) %$S"
        };
    
    // Pull in LoggerCallback
    var LoggerCallback = xdc.useModule('xdc.runtime.LoggerCallback');
    
    // Tell LoggerCallback to call our output function
    LoggerCallback.outputFxn = "&uartLog_outputFxn";
    
    // Tell the Idle module to add our flush() function to the idle loop (before Power)
    //var Idle = xdc.useModule('ti.sysbios.knl.Idle'); // Add if Idle isn't already imported.
    Idle.addFunc('&uartLog_flush');
    
    // Create a static instance of LoggerCallback and set as default Main logger
    var loggerParams = new LoggerCallback.Params();
    loggerParams.arg = 1;
    
    // Only for Main (code that's not in an rtsc module)
    Main.common$.logger = LoggerCallback.create(loggerParams);
    //Defaults.common$.logger = LoggerCallback.create(loggerParams); // Use for all log events
    
    // Turn on USER1 logs and INFO in Main module (user code). Turn off USER2 for fun.
    Main.common$.diags_USER1 = Diags.ALWAYS_ON;
    Main.common$.diags_USER2 = Diags.ALWAYS_ON;
    Main.common$.diags_USER6 = Diags.ALWAYS_ON;
    Main.common$.diags_INFO = Diags.ALWAYS_ON;