Other Parts Discussed in Thread: CC2650STK, SYSBIOS
Hi, I have pasted code below which I am using for duty cycle of 10 seconds. My questions are as following.
1) I have inserted Power_enablePolicy() function at the start of main code. Is this correct way of implementing Power saving mode for CC2650STK or is there other way to implement way for this policy.
2) The following structure has to be called explicitly in main function OR once we call Power_enablePolicy() the structure gets initialized automatically ? If I add this structure in main() function, it gives errors.
const PowerCC26XX_Config PowerCC26XX_config = {
.policyInitFxn = NULL,
.policyFxn = &PowerCC26XX_standbyPolicy,
.calibrateFxn = &PowerCC26XX_noCalibrate, // default is &PowerCC26XX_calibrate
.enablePolicy = TRUE, .calibrateRCOSC_LF = FALSE, // default is TRUE
.calibrateRCOSC_HF = FALSE, // default is TRUE
}
3) In code heartBeatFxn() which runs forever, I have implemented Task_sleep with duty cycle 10 seconds. So led turns on and off turn by turn after every 10 seconds. So, my purpose is to execute Power save mode when Task_sleep is in execution.
4)Do we have to make any changes in empty_min.cfg for implementing power policy?
5) I just want to be sure that Policy for power save gets executed in this sleep condition. Please provide explained answers as there is nothing given how to apply this policy in pdf of power-management.pdf neither do TI has any blog how to implement it.
/*
* ======== 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>
/* TI-RTOS Header files */
// #include <ti/drivers/I2C.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"
/* Power Management Header Files */
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.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
};
/*
* ======== heartBeatFxn ========
* Toggle the Board_LED0. The Task_sleep is determined by arg0 which
* is configured for the heartBeat Task instance.
*/
Void heartBeatFxn(UArg arg0, UArg arg1)
{
while (1) {
Task_sleep((UInt)arg0); // Want sensortag to be in deep sleep mode
PIN_setOutputValue(ledPinHandle, Board_LED0,
!PIN_getOutputValue(Board_LED0));
}
}
/*
* ======== main ========
*/
int main(void)
{
//Enable Power Policy
Power_enablePolicy();
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 = 10000;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)heartBeatFxn, &taskParams, NULL);
/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, ledPinTable);
if(!ledPinHandle) {
System_abort("Error initializing board LED pins\n");
}else{
System_printf("Initialized board LED Pins\n");
}
PIN_setOutputValue(ledPinHandle, Board_LED1, 1);
/* Start BIOS */
BIOS_start();
return (0);
}



