So your task is as easy as selecting a microcontroller (MCU) and then implementing the code that meets your application´s needs. Sounds straightforward, right? Well, both inexperienced and seasoned engineers might recognize some significant challenges here. In this blog series, we´ll take a look at some cross platform tools, tools that run on major operating systems like Microsoft Windows, Mac OS X and Linux, that can really simplify some of the challenges when undertaking a new embedded development project. Read part 2 here.
Part 3- Code Optimization
Video: energyAware Profiler
The major concerns when developing MCU software are typically related to reducing memory usage and having the smallest possible code size. But for applications with a tight energy budget there are other software-dependent factors that enter into the equation.
To achieve energy friendliness, aiming to spend the longest time in sleep mode is a very typical scenario, but it is not the only way to save energy. Energy efficient MCUs are often packed with other functions that enable even lower energy consumption. In addition to the sleep modes available on these MCUs, efficient use of their functions is the real secret for energy sensitive applications.
As the development process moves forward, the code gets larger and optimizing for energy efficiency becomes a hard and time-consuming task. Without proper tools, identifying errors, such as avoidable wait cycles that could be replaced by interrupt service routines, or peripheral misusage, becomes increasingly difficult. If these “energy bugs” are not spotted and solved during the development stage it is virtually impossible to detect them in field or burn-in tests.
The most common way to track how much energy a system draws is by sampling the current over a certain period followed by averaging and extrapolation to longer time periods. This kind of measurement can be done using a multimeter or oscilloscope, but it is not possible to relate the results to code routines. On the other hand, a logic analyzer can be used to keep track of the routines but cannot relate that to the energy consumption. For battery life estimation purposes, the results obtained with extrapolation should not be too far away from a real-case usage scenario, but when you optimize the code for energy efficiency you really want to relate code with energy consumption using development tools.
For example, the ability to view a graphical output of current consumption quickly shows if there are any significant increases in consumption. Taking this a step further, having the ability to click on a point in the graph and profile the application (Figure 3) to show the corresponding line of C code associated with that current consumption is extremely valuable when you develop low-power applications. This means that a developer can trace spikes in the current consumption down to the specific lines of code that caused the spike, and then perform optimizations. Again, this “energy-aware” capability can be especially critical in battery-powered applications where every micro amp and even nano amp counts.
Figure 3. A profiler associates system performance with the corresponding code
When driving toward creating a final code image, developers will surely need some form of technical support or design resources. Comprehensive development ecosystems have integrated resource portals that allow developers to reach technical support, community forums, knowledge bases and applications notes within a single click.
This may seem like a minor point, but when your final code image is due the next week or day and you hit a design issue, quickly finding design support is absolutely critical. You do not want to waste time trying to find the correct support portal. In addition to support channels, providing developers with the most up-to-date information is key to making embedded development simpler.
This means that developers will always have the latest code examples, technical documentations, and software at all times. Ideally, a software development tool will provide all the required support in one location. After solving these issues, developers move on to production-related questions, and this is covered in part 4 here.
Download Simplicity Studio here:
If you have any further questions, visit our community page here. Our team will be happy to help.