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/MSP-EXP430F5529: Reducing power consumption with TI-RTOS

Part Number: MSP-EXP430F5529

Tool/software: TI-RTOS

Following this question, trying to reduce the current consumption of the MSP430F5529, running TI-RTOS.

After trying several things (see below), I still cannot get the current below ~500 uA. Questions:

  • Does using TI-RTOS inherently increases current consumption?
  • Assuming no interrupts are issued (I've disabled the system tick), and that the MCU is in LPM3, does MCLK frequency still effects current consumption?

Test procedure:

  1. I've started with a simple example project (gpiointerrupt_MSP_EXP430F5529LP_TI), and converted it for the MSP-EXP4305529
  2. Disabled SVM H/L, as done in pmm_ex3_lowCurrentConsumption
  3. In gpiointerrupt.cfg, disabled the Clock module, and configured LPM3 on Idle (see cfg file below)

Configuration script:

/*
* 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.
*/



/* ================ Boot configuration ================ */
var Boot = xdc.useModule('ti.catalog.msp430.init.Boot');



/* ================ Defaults (module) configuration ================ */
var Defaults = xdc.useModule('xdc.runtime.Defaults');
/*
* A flag to allow module names to be loaded on the target. Module name
* strings are placed in the .const section for debugging purposes.
*
* Pick one:
* - true (default)
* Setting this parameter to true will include name strings in the .const
* section so that Errors and Asserts are easier to debug.
* - false
* Setting this parameter to false will reduce footprint in the .const
* section. As a result, Error and Assert messages will contain an
* "unknown module" prefix instead of the actual module name.
*/
//Defaults.common$.namedModule = true;
Defaults.common$.namedModule = false;



/* ================ Error configuration ================ */
var Error = xdc.useModule('xdc.runtime.Error');
/*
* This function is called to handle all raised errors, but unlike
* Error.raiseHook, this function is responsible for completely handling the
* error with an appropriately initialized Error_Block.
*
* Pick one:
* - Error.policyDefault (default)
* Calls Error.raiseHook with an initialized Error_Block structure and logs
* the error using the module's logger.
* - Error.policySpin
* Simple alternative that traps on a while(1) loop for minimized target
* footprint.
* Using Error.policySpin, the Error.raiseHook will NOT called.
*/
//Error.policyFxn = Error.policyDefault;
Error.policyFxn = Error.policySpin;

/*
* If Error.policyFxn is set to Error.policyDefault, this function is called
* whenever an error is raised by the Error module.
*
* Pick one:
* - Error.print (default)
* Errors are formatted and output via System_printf() for easier
* debugging.
* - null
* Errors are not formatted or logged. This option reduces code footprint.
* - non-null function
* Errors invoke custom user function. See the Error module documentation
* for more details.
*/
//Error.raiseHook = Error.print;
Error.raiseHook = null;
//Error.raiseHook = "&myErrorFxn";

/*
* If Error.policyFxn is set to Error.policyDefault, this option applies to the
* maximum number of times the Error.raiseHook function can be recursively
* invoked. This option limits the possibility of an infinite recursion that
* could lead to a stack overflow.
* The default value is 16.
*/
Error.maxDepth = 2;



/* ================ Hwi configuration ================ */
var halHwi = xdc.useModule('ti.sysbios.hal.Hwi');
var msp430Hwi = xdc.useModule('ti.sysbios.family.msp430.Hwi');
/*
* Checks for Hwi (system) stack overruns while in the Idle loop.
*
* Pick one:
* - true (default)
* Checks the top word for system stack overflows during the idle loop and
* raises an Error if one is detected.
* - false
* Disabling the runtime check improves runtime performance and yields a
* reduced flash footprint.
*/
halHwi.checkStackFlag = true;
//halHwi.checkStackFlag = false;



/* ================ Idle configuration ================ */
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
/*
* The Idle module is used to specify a list of functions to be called when no
* other tasks are running in the system.
*
* Functions added here will be run continuously within the idle task.
*
* Function signature:
* Void func(Void);
*/
//Idle.addFunc("&myIdleFunc");



/* ================ Kernel (SYS/BIOS) configuration ================ */
var BIOS = xdc.useModule('ti.sysbios.BIOS');
/*
* Enable asserts in the BIOS library.
*
* Pick one:
* - true (default)
* Enables asserts for debugging purposes.
* - false
* Disables asserts for a reduced code footprint and better performance.
*/
//BIOS.assertsEnabled = true;
BIOS.assertsEnabled = false;

/*
* Specify default heap size for BIOS.
*/
BIOS.heapSize = 0;

/*
* A flag to determine if xdc.runtime sources are to be included in a custom
* built BIOS library.
*
* Pick one:
* - false (default)
* The pre-built xdc.runtime library is provided by the respective target
* used to build the application.
* - true
* xdc.runtime library sources are to be included in the custom BIOS
* library. This option yields the most efficient library in both code
* footprint and runtime performance.
*/
BIOS.includeXdcRuntime = false;
//BIOS.includeXdcRuntime = true;

/*
* The SYS/BIOS runtime is provided in the form of a library that is linked
* with the application. Several forms of this library are provided with the
* SYS/BIOS product.
*
* Pick one:
* - BIOS.LibType_Custom
* Custom built library that is highly optimized for code footprint and
* runtime performance.
* - BIOS.LibType_Debug
* Custom built library that is non-optimized that can be used to
* single-step through APIs with a debugger.
*
*/
BIOS.libType = BIOS.LibType_NonInstrumented;
//BIOS.libType = BIOS.LibType_Debug;

/*
* Runtime instance creation enable flag.
*
* Pick one:
* - true (default)
* Allows Mod_create() and Mod_delete() to be called at runtime which
* requires a default heap for dynamic memory allocation.
* - false
* Reduces code footprint by disallowing Mod_create() and Mod_delete() to
* be called at runtime. Object instances are constructed via
* Mod_construct() and destructed via Mod_destruct().
*/
BIOS.runtimeCreatesEnabled = true;
//BIOS.runtimeCreatesEnabled = false;

/*
* Enable logs in the BIOS library.
*
* Pick one:
* - true (default)
* Enables logs for debugging purposes.
* - false
* Disables logging for reduced code footprint and improved runtime
* performance.
*/
//BIOS.logsEnabled = true;
BIOS.logsEnabled = false;



/* ================ Memory configuration ================ */
var Memory = xdc.useModule('xdc.runtime.Memory');
/*
* The Memory module itself simply provides a common interface for any
* variety of system and application specific memory management policies
* implemented by the IHeap modules(Ex. HeapMem, HeapBuf).
*/



/* ================ Power configuration ================ */
var Power = xdc.useModule('ti.sysbios.family.msp430.Power');
/*
* Dynamically change idle mode power settings.
*
* Pick one:
* - true
* Allow for dynamic waking of the CPU when returning
* from an interrupt at runtime.
* - false (default)
* Disable run-time checking of this parameter; Yields a
* small code saving.
*/
//Power.allowDynamicMode = true;
Power.allowDynamicMode = false;

/*
* Behavior of the power module when the system enters the idle loop.
*
* Pick one:
* - false (default)
* Disables power savings and ignores the power policy function.
* - true
* The power module inserts a power policy function into the idle loop
* where it will take action to save power until the next CPU interrupt
* occurs. This option can cause the debugger to be disconnected from the
* target.
*/
Power.idle = true;
//Power.idle = true;

/*
* These options only apply if Power.idle is set to true. The Power.idleMode
* parameter determines the system's behavior when it enters the idle loop.
*
* Pick one:
* - Power.LPM0 (default)
* - Power.LPM1
* - Power.LPM2
* - Power.LPM3
* - Power.LPM4
* See the Operating Modes section of the respective
* MSP430's User Guide for a detailed explanation of these modes.
*/
//Power.idleMode = Power.LPM0;
//Power.idleMode = Power.LPM1;
//Power.idleMode = Power.LPM2;
//Power.idleMode = Power.LPM3;
//Power.idleMode = Power.LPM4;



/* ================ Program configuration ================ */
/*
* Program.stack is ignored with IAR. Use the project options in
* IAR Embedded Workbench to alter the system stack size.
*/
if (!Program.build.target.$name.match(/iar/)) {
/*
* Reducing the system stack size (used by ISRs and Swis) to reduce
* RAM usage.
*/
Program.stack = 768;
}



/*
* Uncomment to enable Semihosting for GNU targets to print to the CCS console.
* Please read the following TIRTOS Wiki page for more information on Semihosting:
* processors.wiki.ti.com/.../TI-RTOS_Examples_SemiHosting
*/

if (Program.build.target.$name.match(/gnu/)) {
//var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
}



/* ================ Semaphore configuration ================ */
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
/*
* Enables global support for Task priority pend queuing.
*
* Pick one:
* - true (default)
* This allows pending tasks to be serviced based on their task priority.
* - false
* Pending tasks are services based on first in, first out basis.
*
* When using BIOS in ROM:
* This option must be set to false.
*/
//Semaphore.supportsPriority = true;
Semaphore.supportsPriority = false;

/*
* Allows for the implicit posting of events through the semaphore,
* disable for additional code saving.
*
* Pick one:
* - true
* This allows the Semaphore module to post semaphores and events
* simultaneously.
* - false (default)
* Events must be explicitly posted to unblock tasks.
*
*/
//Semaphore.supportsEvents = true;
Semaphore.supportsEvents = false;



/* ================ Swi configuration ================ */
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
/*
* A software interrupt is an object that encapsulates a function to be
* executed and a priority. Software interrupts are prioritized, preempt tasks
* and are preempted by hardware interrupt service routines.
*
* This module is included to allow Swi's in a users' application.
*/



/* ================ System configuration ================ */
var System = xdc.useModule('xdc.runtime.System');
/*
* The Abort handler is called when the system exits abnormally.
*
* Pick one:
* - System.abortStd (default)
* Call the ANSI C Standard 'abort()' to terminate the application.
* - System.abortSpin
* A lightweight abort function that loops indefinitely in a while(1) trap
* function.
* - A custom abort handler
* A user-defined function. See the System module documentation for
* details.
*/
//System.abortFxn = System.abortStd;
System.abortFxn = System.abortSpin;
//System.abortFxn = "&myAbortSystem";

/*
* The Exit handler is called when the system exits normally.
*
* Pick one:
* - System.exitStd (default)
* Call the ANSI C Standard 'exit()' to terminate the application.
* - System.exitSpin
* A lightweight exit function that loops indefinitely in a while(1) trap
* function.
* - A custom exit function
* A user-defined function. See the System module documentation for
* details.
*/
//System.exitFxn = System.exitStd;
System.exitFxn = System.exitSpin;
//System.exitFxn = "&myExitSystem";

/*
* Minimize exit handler array in the System module. The System module includes
* an array of functions that are registered with System_atexit() which is
* called by System_exit(). The default value is 8.
*/
System.maxAtexitHandlers = 2;

/*
* The System.SupportProxy defines a low-level implementation of System
* functions such as System_printf(), System_flush(), etc.
*
* Pick one pair:
* - SysMin
* This module maintains an internal configurable circular buffer that
* stores the output until System_flush() is called.
* The size of the circular buffer is set via SysMin.bufSize.
* - SysCallback
* SysCallback allows for user-defined implementations for System APIs.
* The SysCallback support proxy has a smaller code footprint and can be
* used to supply custom System_printf services.
* The default SysCallback functions point to stub functions. See the
* SysCallback module's documentation.
*/
var SysMin = xdc.useModule('xdc.runtime.SysMin');
SysMin.bufSize = 128;
System.SupportProxy = SysMin;



/* ================ Text configuration ================ */
var Text = xdc.useModule('xdc.runtime.Text');
/*
* These strings are placed in the .const section. Setting this parameter to
* false will save space in the .const section. Error, Assert and Log messages
* will print raw ids and args instead of a formatted message.
*
* Pick one:
* - true (default)
* This option loads test string into the .const for easier debugging.
* - false
* This option reduces the .const footprint.
*/
//Text.isLoaded = true;
Text.isLoaded = false;



/* ================ Types configuration ================ */
var Types = xdc.useModule('xdc.runtime.Types');
/*
* This module defines basic constants and types used throughout the
* xdc.runtime package.
*/



/* ================ TI-RTOS middleware configuration ================ */
var mwConfig = xdc.useModule('ti.mw.Config');
/*
* Include TI-RTOS middleware libraries
*/



/* ================ TI-RTOS drivers' configuration ================ */
var driversConfig = xdc.useModule('ti.drivers.Config');
/*
* Include TI-RTOS drivers
*
* Pick one:
* - driversConfig.LibType_NonInstrumented (default)
* Use TI-RTOS drivers library optimized for footprint and performance
* without asserts or logs.
* - driversConfig.LibType_Instrumented
* Use TI-RTOS drivers library for debugging with asserts and logs enabled.
*/
driversConfig.libType = driversConfig.LibType_NonInstrumented;
//driversConfig.libType = driversConfig.LibType_Instrumented;



/* ================ Application Specific Instances ================ */

/* Use UARTMon with TI toolchain only */
if (!Program.build.target.$name.match(/iar/)) {
var UARTMon = xdc.useModule('ti.tirtos.utils.UARTMon');
}

/*
* Static Hwi isntance creation, required for MSP430.
*
* Functions added here will be run given a hardware interrupt occurrs.
*
* Function signature:
* Void func(UArg);
*/

var hwiParams = new halHwi.Params();

/* Add the GPIO port number as Hwi argument */
hwiParams.arg = 2;
halHwi.create(42, "&GPIO_hwiIntFxn", hwiParams);

/* Add the GPIO port number as Hwi argument */
hwiParams.arg = 1;
halHwi.create(47, "&GPIO_hwiIntFxn", hwiParams);

/*
* Add UART index number as Hwi argument.
* This argument is used to index into the UART peripherial array
* declared in the board.c file.
*/
hwiParams.arg = 0;
halHwi.create(46, "&UARTUSCIA_hwiIntFxn", hwiParams);
Power.idleMode = Power.LPM3;