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.

CC2652RB: Does timer block power policy?

Part Number: CC2652RB
Other Parts Discussed in Thread: SYSCONFIG, SIMPLELINK-CC13X2-26X2-SDK, Z-STACK

I want to call a function at 1Hz with "sleep" in between. I thought a timer was going to solve this, here's the timer:

Timer_Params_init(&timerParams);
timerParams.period = 1;
timerParams.periodUnits = Timer_PERIOD_HZ;
timerParams.timerMode = Timer_CONTINUOUS_CALLBACK;
timerParams.timerCallback = timerCallback;
timer0 = Timer_open(CONFIG_TIMER_0, &timerParams);
if (timer0 == NULL) { // failed init
	while (1) {
	}
}
if (Timer_start(timer0) == Timer_STATUS_ERROR) {
	while (1) { // failed start
	}
}

Inside mainThread(), at the bottom I have:

while (1) {
    Task_sleep(100000);
}

While my timer callback works, current hovers at ~1.5mA, so the device is not sleeping. If instead, I remove the timer and just make my own callback function in the while loop, I observe power savings at ~23uA:

while (1) {
    Task_sleep(100000);
    loopCallback();
}

What is it about the timer that's doing this? Is it possible that it's keeping the HF crystal on? I'm using BAW resonator with LF RCOSC. 

  • Hi Matt,

    You should be able to enter device sleep states in between servicing a timer interrupt.  Please review the timerled example and TI Driver Runtime APIs.  Are you evaluating with a LP-CC2652RB and how are you measuring the current consumption?

    Regards,
    Ryan

  • Hi Ryan, I'm actually programming a standalone PCB, so my ammeter is inline with the battery itself. I just re-tested and get the same behavior if I replace the last while() loop with a return(NULL) as done in timerled, but that's the only thing I see that is different. Again, if I use Task_sleep in that while loop without the timer, everything sleeps just fine, and I can toggle an LED in there instead of the timer callback. My timer is configured the same in Sysconfig to timerled.

  • By "same behavior" do you mean expected power consumption or over-consumption?  What is the power consumption when operating timerled out-of-box?  Have you reviewed the Timer and Power APIs?

    Regards,
    Ryan

  • To achieve the lowest power with timerled I have to modify SysConfig to use LF RCOSC and use a while loop with Task_sleep (see modification below). The same problem exists, the timer works but doesn't achieve sleep in between GPIO_toggle. There's nothing to indicate in the API why I wouldn't achieve sleep, and my expectation was the same as yours (it should work): is it possible that the timer is forcing use of LF XOSC? With would force the main resonator to remain on and may be a source of the ~0.8mA I'm seeing.

    /*
     *  ======== timerled.c ========
     */
    
    #include <stddef.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/Timer.h>
    #include <ti/sysbios/knl/Task.h>
    
    /* Board Header file */
    #include "ti_drivers_config.h"
    
    /* Callback used for toggling the LED. */
    void timerCallback(Timer_Handle myHandle, int_fast16_t status);
    
    /*
     *  ======== mainThread ========
     */
    void* mainThread(void *arg0) {
    	Timer_Handle timer0;
    	Timer_Params params;
    
    	/* Call driver init functions */
    	GPIO_init();
    	Timer_init();
    
    	/* Configure the LED pin */
    	GPIO_setConfig(LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
    	/* Turn off user LED */
    	GPIO_write(LED_0, CONFIG_GPIO_LED_OFF);
    
    	/*
    	 * Setting up the timer in continuous callback mode that calls the callback
    	 * function every 1,000,000 microseconds, or 1 second.
    	 */
    	Timer_Params_init(&params);
    	params.period = 1000000;
    	params.periodUnits = Timer_PERIOD_US;
    	params.timerMode = Timer_CONTINUOUS_CALLBACK;
    	params.timerCallback = timerCallback;
    
    //	timer0 = Timer_open(CONFIG_TIMER_0, &params);
    //	if (timer0 == NULL) {
    //		/* Failed to initialized timer */
    //		while (1) {
    //		}
    //	}
    //
    //	if (Timer_start(timer0) == Timer_STATUS_ERROR) {
    //		/* Failed to start timer */
    //		while (1) {
    //		}
    //	}
    
    //	return(NULL);
    
    	while(1) {
    		Task_sleep(100000);
    		GPIO_toggle(LED_0);
    	}
    }
    
    /*
     * This callback is called every 1,000,000 microseconds, or 1 second. Because
     * the LED is toggled each time this function is called, the LED will blink at
     * a rate of once every 2 seconds.
     */
    void timerCallback(Timer_Handle myHandle, int_fast16_t status) {
    	GPIO_toggle(LED_0);
    }

  • As you can see from the table in Section 5.5 (Power Consumption - Power Modes) of the Datasheet, the difference in power consumption between XOSC_LF and RCOSC_LF is a matter of 0.1 µA.  Both are also available in standby mode (Table 6-1).  What happens when you leave SysConfig at the LF XOSC source setting?

    Regards,
    Ryan

  • These two measures are the code above (Task_sleep in while loop), LED off, only difference is XOSC_LF vs. RCOSC_LF. That said, using RCOSC_LF with the timer doesn't 'fix' anything—LED off current with RCOSC_LF using the timer is 0.84mA.

  • Hi Matt,

    Please refer to SWRA649 and SWRA499.  Do you know what the behavior is with the LP-CC2652RB which has an external LF crystal?

    Regards,
    Ryan

  • Ryan, refer to what parts? Is there something in there that resolves my issue (using Timer)? I don't know the behavior with the LP/external crystal. The point of using BAW for me is to reduce BOM.

  • All of SWRA649, I don't know, and apologies for my previous comment which was made without thinking through the device which is being used.  What is your SIMPLELINK-CC13X2-26X2-SDK version?

    Regards,
    Ryan

  • I don't see anything that would help me with this issue in SWRA649. I'm not migrating. I'm using LF RCOSC because it's low cost and low power. SDK simplelink_cc13x2_26x2_sdk_4_40_00_44. Thanks

  • Hey Matt,

    I apologize for the confusion.  ~860 µA is expected when using the timer peripheral according to this E2E post, regardless of LFOSC source.  Z-Stack and others use util_timer which allows for standby mode operation.

    Regards,
    Ryan

  • Interesting, thanks.