C compilers for micro-controllers in general and for MSP430 MCUs specifically allocate the variables declared in the global scope into the RAM location of the memory structure. On the other hand, local variables are first allocated into CPU registers (until the function runs out of the CPU registers for its local variables). Accesses to CPU registers are the most efficient and quickest, when compared to accesses to memory locations in RAM or even worse, in FLASH. Therefore, any global variables that are only accessed within one function can be safely relocated into the function local scope to optimize the memory access speed and power consumption.
Using global variables that can be otherwise be declared locally could decrease the memory access speed efficiency and hence increase power consumption.
ULP Advisor detects a static global variable that is only accessed within one function of the project.
Place the variable in question in the function locally instead of declaring it globally.
See the rest of the code examples for all MSP430 devices here!
Want to squeeze a few more nanoAmps out of your application? Leverage the e2e (Engineer-to-Engineer) online community to get all of your ULP questions answered! Or, if you are an Ultra-Low Power pro, give back to the community with your expertise.
Go to MSP430's e2e online forum!
If you are posting on the forums in relation to this rule, try using the tag "ULP_7.1"
![]() |
For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Compiler/diagnostic messages/MSP430/1534 here. |