Other Parts Discussed in Thread: SYSBIOS, , CC1310, CC2541
Tool/software: TI-RTOS
hello,
I measure the total consumption of my personal PCB (CC1310 4x4 mm) intrefacée with a Tmp 116 sensor, in standby mode and I get readings around 129 μA. Our application requires a total system current consumption of less than 4 μA. What steps are we taking to achieve this, please?
NB: Mon capteur consomme 129 μA and i used the sail librairy?
I'm working with the SDK for simplelink_CC13x0 and using CCS 8.0.
This is my code:
/*
* 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.
*/
/*
* ======== rfEasyLinkTx.c ========
*/
/* XDCtools Header files */
#include <pthread.h>
#include <stdlib.h>
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
#include <stdint.h>
#include <stddef.h>
#include <unistd.h>
#include <semaphore.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
/* BIOS Header files */
#include <ti/drivers/rf/RF.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/I2C.h>
/* TI-RTOS Header files */
#include <ti/drivers/PIN.h>
#include <ti/drivers/Power.h>
#include <ti/devices/cc13x0/driverlib/aon_batmon.h>
#include <ti/devices/cc13x0/driverlib/aux_adc.h>
#include <ti/devices/cc13x0/driverlib/chipinfo.h>
#include <ti/devices/cc13x0/driverlib/sys_ctrl.h>
#include <semaphore.h>
#include <ti/sail/tmp116/tmp116.h>
/* Board Header files */
#include "Board.h"
/* EasyLink API Header files */
#include "easylink/EasyLink.h"
#include "sc/scif.h"
#include "version.h"
#include "../sonde_gw_fw/sys_intf.h"
#include <string.h>
#include <math.h>
#define RFEASYLINKTX_TASK_STACK_SIZE 1024
#define RFEASYLINKTX_TASK_PRIORITY 2
#define RFEASYLINKTX_BURST_SIZE 1
Task_Struct txTask; /* not static so you can see in ROV */
static Task_Params txTaskParams;
static uint8_t txTaskStack[RFEASYLINKTX_TASK_STACK_SIZE];
Task_Struct sensorTask; /* not static so you can see in ROV */
static Task_Params sensorTaskParams;
static uint8_t sensorTaskStack[RFEASYLINKTX_TASK_STACK_SIZE];
typedef struct {
uint8_t reason;
int16_t temp_deg_frac_8;
uint8_t bat_20mV;
} opto_sonde_data_t;
void sleepAndReset(uint32_t sleep_time_secs) {
// Enable button interrupt wake up
uint32_t secs = sleep_time_secs;
while (secs > 0)
{
uint32_t sleep_s = secs > 2000 ? 2000 : secs;
Task_sleep((sleep_s * 1000u * 1000) / Clock_tickPeriod);
secs -= sleep_s;
}
SysCtrlSystemReset();
}
static void rfEasyLinkTxFnx(UArg arg0, UArg arg1)
{
opto_sonde_data_t* optosonde_data = (opto_sonde_data_t*) arg0;
// rtc_cmd_t* rtc_cmd = arg1;
// EasyLink_init(EasyLink_Phy_625bpsLrm);
// EasyLink_init(EasyLink_Phy_5kbpsSlLr);
EasyLink_init(EasyLink_Phy_Custom);
/*
* If you wish to use a frequency other than the default, use
* the following API:
* EasyLink_setFrequency(868000000);
*/
/* Set output power to 12dBm */
// EasyLink_setRfPwr(12);
EasyLink_setRfPwr(10);
EasyLink_TxPacket txPacket;
// Fill packet data
uint8_t payload_ptr = 0;
// Payload version
txPacket.payload[payload_ptr++] = (uint8_t) (0x0);
// Src MAC
EasyLink_getIeeeAddr(&txPacket.payload[payload_ptr]);
payload_ptr += 8;
// Copy data
txPacket.payload[payload_ptr++] = (uint8_t) (optosonde_data->reason);
txPacket.payload[payload_ptr++] = (uint8_t) (optosonde_data->temp_deg_frac_8 >> 8);
txPacket.payload[payload_ptr++] = (uint8_t) (optosonde_data->temp_deg_frac_8);
txPacket.payload[payload_ptr++] = (uint8_t) (optosonde_data->bat_20mV);
// Firmware version
memcpy(&txPacket.payload[payload_ptr], &VERSION_HASH, sizeof(VERSION_HASH));
payload_ptr += sizeof(VERSION_HASH);
txPacket.len = payload_ptr;
txPacket.absTime = 0;
txPacket.dstAddr[0] = OPTOSONDE_ADDR;
EasyLink_Status result = EasyLink_transmit(&txPacket);
if (result == EasyLink_Status_Success)
{
/* Toggle LED1 to indicate TX */
// PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
}
else
{
/* Toggle LED1 and LED2 to indicate error */
// PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
// PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
}
// Prevent button reset overload
if (optosonde_data->reason == optosonde_reason_button) {
Task_sleep(1000000 / Clock_tickPeriod);
}
Task_sleep(5000 * 100);
// Tell RTC to sleep
uint32_t sleep_time_s = 1 * 30;
sleepAndReset(sleep_time_s);
}
void sendorTask(UArg arg0, UArg arg1)
{
static opto_sonde_data_t optosonde_data;
float temperature;
I2C_Handle i2c;
TMP116_Handle tmp116Handle;
I2C_Params i2cParams;
I2C_Params_init(&i2cParams);
i2cParams.transferMode = I2C_MODE_BLOCKING;
i2cParams.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C_TMP, &i2cParams);
if (i2c == NULL) {
}
else {
}
TMP116_init();
tmp116Handle = TMP116_open(Board_I2C_TMP, i2c, NULL);
if (tmp116Handle == NULL){
}else
{
}
sleep(2);
if (TMP116_getTemp(tmp116Handle, TMP116_CELSIUS, &temperature)) {
}
else {
}
if (TMP116_close(tmp116Handle)){
} else {
}
I2C_close(i2c);
uint16_t MSB = (uint8_t) (temperature);
uint8_t LSB = (uint8_t) ((temperature - MSB ) * 100);
optosonde_data.temp_deg_frac_8 = (MSB<<8) +LSB;
while (!AONBatMonNewBatteryMeasureReady())
{
// Wait
Task_sleep(1000 * 1000 / Clock_tickPeriod);
}
optosonde_data.bat_20mV = (AONBatMonBatteryVoltageGet() * 390625) / 2000000;
AONBatMonDisable();
// Init Tx task
Task_Params_init(&txTaskParams);
txTaskParams.stackSize = RFEASYLINKTX_TASK_STACK_SIZE;
txTaskParams.priority = RFEASYLINKTX_TASK_PRIORITY + 1;
txTaskParams.stack = &txTaskStack;
txTaskParams.arg0 = (xdc_UArg) &optosonde_data;
Task_construct(&txTask, rfEasyLinkTxFnx, &txTaskParams, NULL);
}
/*
* ======== main ========
*/
int opto_main(void)
{
/* Call driver init functions. */
Board_initGeneral();
Board_initI2C();
// Sensor task
Task_Params_init(&sensorTaskParams);
txTaskParams.stackSize = RFEASYLINKTX_TASK_STACK_SIZE;
txTaskParams.priority = RFEASYLINKTX_TASK_PRIORITY;
txTaskParams.stack = &sensorTaskStack;
txTaskParams.arg0 = 0;
txTaskParams.arg1 = 0;
Task_construct(&sensorTask,sendorTask,&sensorTaskParams, NULL);
/* Start BIOS */
BIOS_start();
return (0);
}