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/LAUNCHXL-CC1310: RF driver interfering with Power driver

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

Tool/software: TI-RTOS

Hello,

I made a big program wich involves RF, TDC, tasks, clocks, etc. Yesterday I realized that it is not entering standby mode , the power consumption when all tasks are blocked is above 10 mA.

I verified that the power policy is selected and enabled, I've made a modification to be notified wheter it goes to standbymode or wakes up from it, with that I confirmed that it's not going on standby.

Well, the next thing I do was to probe the notifications with an empty project and it worked, everytime a task is blocked, it goes on standby mode. So, The problem was in my program, so I began taking out one by one different parts of it that could be blocking the power driver. After 6 hours, I realized that the problem was the RF driver, when I took out the RF command lines, it began going on standby mode.

So, next thing to do was to introduce the notifiacations system on an RF example (rfPacketTx, cause it's very alike to the RF section of my program) and curiously, it DID go to standby mode so I compared it with my program and start modifing the example to make it alike my program.

At the end, the change that makes the power driver fails is the configuration of the TX opperation:

-As the example is, it is configured to trigger at an Abosolute Time, and the time variable is incremented in every iteration of a loop so you get a sinchonous trasnsmitter. With these, I get the notifications:

XOSC_HF_SWITCHED

ENTERING_STANDBY

AWAKE_STANDBY_LATE

XOSC_HF_SWITCHED

ENTERING STANDBY

ETC

- But, when I change the "absolute time" to "trigger now" or "relative time" it stops entering to standby mode. It fails also if I leave it on "absolute time" and change the period to 0. The notifications received where:

XOSC_HF_SWITCHED 

(AND NO MORE)

I tried everything:

-Change RunCmd for PostCmd

-Change the LF OSC in the ccfg.c file (driverlib/startup_files)

-Disable the calibration of OSC in the PowerCC26XXX_config struct, wich is in the CC1310_LAUNCHXL.c file

PD: In the sensor controller studio code, I've got implemented the peripheral sharing functions for TDC (I read that it prevents it from interfering the power driver), SO, that's not the issue...

Here is the code of the example wich I was modifying (I post it in the way it enters to the santdby mode with the notifications modification):

/*
 * Copyright (c) 2015-2016, 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.
 */

/***** Includes *****/
#include <stdlib.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

/* Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>

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

#include "smartrf_settings/smartrf_settings.h"

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

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

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


/***** Defines *****/
#define TX_TASK_STACK_SIZE 1024
#define TX_TASK_PRIORITY   2

/* Packet TX Configuration */
#define PAYLOAD_LENGTH      30
#define PACKET_INTERVAL     (uint32_t)(4000000*3) /* Set packet interval to 500ms */



/***** Prototypes *****/
static void txTaskFunction(UArg arg0, UArg arg1);
int powerfunction(unsigned int eventType, uintptr_t eventArg, uintptr_t clientArg);
Power_NotifyObj powerobj;

/***** Variable declarations *****/
static Task_Params txTaskParams;
Task_Struct txTask;    /* not static so you can see in ROV */
static uint8_t txTaskStack[TX_TASK_STACK_SIZE];

static RF_Object rfObject;
static RF_Handle rfHandle;

uint32_t time;
static uint8_t packet[PAYLOAD_LENGTH];
static uint16_t seqNumber;
static PIN_Handle pinHandle;


/***** Function definitions *****/
void TxTask_init(PIN_Handle inPinHandle)
{
    pinHandle = inPinHandle;

    Task_Params_init(&txTaskParams);
    txTaskParams.stackSize = TX_TASK_STACK_SIZE;
    txTaskParams.priority = TX_TASK_PRIORITY;
    txTaskParams.stack = &txTaskStack;
    txTaskParams.arg0 = (UInt)1000000;

    Task_construct(&txTask, txTaskFunction, &txTaskParams, NULL);
}

int powerfunction(unsigned int eventType, uintptr_t eventArg, uintptr_t clientArg){
    switch(eventType){
    case PowerCC26XX_ENTERING_STANDBY:
        System_printf("entering standby\n");
        System_flush();
        break;
    case PowerCC26XX_AWAKE_STANDBY:
        System_printf("awake standby\n");
        System_flush();
        break;
    case PowerCC26XX_ENTERING_SHUTDOWN:
            System_printf("entering shutdown\n");
            System_flush();
            break;
    case PowerCC26XX_AWAKE_STANDBY_LATE:
            System_printf("awake standby late\n");
            System_flush();
            break;
    case PowerCC26XX_XOSC_HF_SWITCHED:
            System_printf("xosc hf switched\n");
            System_flush();
            break;
    }
    return Power_NOTIFYDONE;
}

static void txTaskFunction(UArg arg0, UArg arg1)
{
    uint32_t time;
    RF_Params rfParams;
    RF_Params_init(&rfParams);

    RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
    RF_cmdPropTx.pPkt = packet;
    RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
    RF_cmdPropTx.startTrigger.pastTrig = 1;
    RF_cmdPropTx.startTime = 0;

    /* Request access to the radio */
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);

    /* Set the frequency */
    RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);

    /* Get current time */
    time = RF_getCurrentTime();
    while(1)
    {
        Task_sleep(1000*(1000/Clock_tickPeriod));
        /* Create packet with incrementing sequence number and random payload */
        packet[0] = (uint8_t)(seqNumber >> 8);
        packet[1] = (uint8_t)(seqNumber++);
        uint8_t i;
        for (i = 2; i < PAYLOAD_LENGTH; i++)
        {
            packet[i] = rand();
        }

        /* Set absolute TX time to utilize automatic power management */
        time += PACKET_INTERVAL;
        RF_cmdPropTx.startTime = time;

        /* Send packet */
        RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
        if (!(result & RF_EventLastCmdDone))
        {
            /* Error */
            while(1);
        }

        PIN_setOutputValue(pinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
    }
}

/*
 *  ======== main ========
 */
int main(void)
{
    /* Call board init functions. */
    Board_initGeneral();

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

    /* Initialize task */
    TxTask_init(ledPinHandle);

    Power_registerNotify(&powerobj, 25 , &powerfunction, 0);

    /* Start BIOS */
    BIOS_start();

    return (0);
}