Adapting MCU software to meet your design needs -

Adapting MCU software to meet your design needs


This “Product How-To” article focuses how to use a certain product in an embedded system and is written by a company representative.

As the world continues to go digital, microcontrollers (MCUs) are being introduced to more applications than ever. New televisions use MCUs to increase the contrast ratio with LEDs.

Lawnmowers can be automated with the help of MCUs, and use electric motors instead of gasoline engines to improve efficiency and reduce pollution. Coffee makers are made smarter with the addition of an MCU to make the perfect cup right when you wake up.

With the growth of MCUs comes a wave of developers with a variety of different backgrounds. This forces us to take another look at MCU software development. In order to maximize the usability of the processor, MCU software must appeal to the wide audience of users and place a larger emphasis on system applications.

Catering to Different Programming Preferences
MCUs are no longer being programmed by only seasoned embedded systems engineers. New applications and the widespread availability of MCUs attract engineers who have never touched digital hardware before, hobbyists with only a passion for technology, and even artists looking for a new way to express their talents.

These new capabilities require that developers break away from traditional, fixed way of programming MCUs and move to methodologies that provide them with a number of different levels of abstraction and control.

To provide that capability, TI designers developed the controlSUITE software for the company's Piccolo C2000 MCUs with a 4-level hardware abstraction layer (HAL) that enables such flexibility (Figure 1 below ).

Figure 1. Different programmers with varying backgrounds and preferences can program C2000 MCUs their way with the 4 hardware abstraction layers enabled by controlSUITE software.

Level #1. Starting from the very bottom, registers and addresses can be referenced directly as they always have been.

Level #2. But building from there, the second level, bit fields, allows registers and the functional groups of bits within them to be accessed like variables. By mapping registers to memory, programmers can now access and store values into bits or functional groups of bits as if modifying a variable, and can also watch them like variables in real-time.

This eliminates confusing and error-prone methods like bit-masking. Bit fields appeal to experienced MCU programmers by providing complete access to the device while making programming easier.

Level #3. Taking a step even further, an API of peripheral drivers allows users to program the peripherals with simple function calls. For example, initializing and setting up a PWM can be done by calling functions and passing them parameters like period, duty cycle, and channel number.

These peripheral API drivers provide a simpler interface to new embedded programmers (or a familiar function-call interface to PC software developers.)

Level #4. Finally, a complete baseline framework enables new users to jump into their application without having to worry about setup code, including task management and GPIO mapping.

Combined, these four levels, and the ability to move amongst them, give a programmer the ability to quickly implement simple functions while simultaneously providing full access to take full advantage of C2000's control-oriented peripherals.

Modular Software for Every Design Stage.
MCU evaluation kits are expected to come with example software to help users get started. But with engineers moving outside their areas of expertise to add features and intelligence to their projects, simple example software is not enough.

Software is needed throughout the design cycle, from evaluation examples to device libraries to application development. Developers looking to add voice recognition or image processing may not have extensive experience with FFTs.

Mechanical engineers designing robotic arms may not have experience with digital motor control. And it can take a copious amount of time to learn about signal processing or control algorithms.

To provide support at each step in this process, the controlSUITE software repertoire incorporates a thorough set of evaluation examples can be used as a starting point for development. These examples show the bit fields and API library from the HAL.

An extensive library repository provides engineers with a base set of code to work with. Basic math and trig libraries are expected from MCU suppliers, but controlSUITE software goes beyond the basics.

Because it supports an MCU family with strong math processing capabilities inherited from the 32-bit, pipelined C28x core, controlSUITE software also includes DSP libraries and algorithms for FFTs and filters.

IQMath: Uniquely useful for C2000 programmers
IQMath is a library and compiler intrinsic that allows you to select your range and resolution by choosing which bits of your binary represented number are integer (I) and which are the quotient (Q).

It allows you to write C functions in floating point format instead of dealing with fixed point scaling, and the compiler takes care of the rest. Writing in IQ Math also allows a single source set to be compiled for fixed-point MCUs or for floating-point MCUs, allowing portability between our devices.

Finally, application libraries provide the building blocks that lay at the foundation of different systems. The application libraries in controlSUITE take the common fundamentals of application systems, such as motor control and power conversion, and puts them into a modular set of functions and macros, complete with documentation and theory.

Implementing a new system can be as simple as connecting inputs to outputs. For example, the Digital Motor Control library contains nearly 30 macros including transforms, estimators, control algorithms and peripheral drivers.

These modules that controlSUITE software provides allow developers to cut down on the time spent implementing the basics, and enable them to focus on differentiating from their competition.

Figure 2. controlSUITE provides modular software every step of the way

Code Efficiency
The effort to reduce pollution or extend battery life results in big pushes in efficiency. Both software and hardware play roles in increasing system efficiency. Much focus is placed on hardware efficiency, and it's time software holds up its end of the deal as well.

The math and DSP libraries in controlSUITE software contain different sets that are optimized for different types of processors ” fixed-point, floating-point and Piccolo's revolutionary Control Law Accelerator (CLA). In addition, the application libraries are built from the ground up to minimize execution time.

For example, controlSUITE software includes a Digital Motor Control library that moves to a macro-based format, where library modules are substituted in place of the macro calls at compile-time.

Such a schema eliminates cycles associated with context switches involved in traditional libraries. Such measures not only increase efficiency, but result in more headroom for system support functions or implementation of industrial standards.

Demonstration Systems vs. Development Systems
The increased focus on application systems produces another problem for designers ” demonstration systems and reference designs prove concepts, but taking those designs and making them work with different setups can be extremely difficult and sometimes impossible.

For example, many kits exist that provide fully working, advanced motor control closed loop reference designs. But significant modification is required to take those kits to custom systems and spinning up and then debugging different motors on different topologies.

C2000 application kits are designed from the ground up to be full development kits. The hardware is composed of modules that can be reused or modified. The bill of materials, schematics and layouts are all free for users to take and improve as they see fit.

On the software side, all controlSUITE-based kits use an incremental build system. With this system, a user can start simple and slowly add more components as they progress through development.

Let's take a closer look at the software for C2000's Dual Motor Control and PFC Kit, for eample. This kit not only demonstrates sensorless field oriented motor control, but presents the software in five build levels to guide users through the system (Figure 3, below ).

Figure 3. A five level incremental build system that starts from simple PWM waveform verification to sensorless field-oriented control on a closed-loop motor control system.

As shown above, Build Level 1 simply implements a minimum system check-out which confirms operations of system interrupts and verifies that the correct waveforms are produced from the Inverse Park, Space Vector, and PWM driver modules.

Build Level 2 verifies the analog-to-digital conversion and phase voltage calculations while adding offset compensation and Clarke / Park transformations.

In Build Level 3 , we add real PID modules and verify the dq-axis current regulation.

After that, Build Level 4 includes rotor position estimation and speed estimation modules.

Finally, Build Level 5 closes the speed loop by using the measured speed as a feedback, which completes the system.

Such a setup, along with full documentation and theory, creates a kit that fosters quick learning of the application, speedy modification to different systems, and makes it easier to debug.

Making it Easy
In the retail software and consumer electronics world, a lot of emphasis is placed on user experience. But, traditionally, this term has rarely been mentioned in MCU or DSP software.

Embedded programmers are accustomed to the inconveniences that plague MCU software development, but new programmers may find such barriers extremely frustrating, with a number of questions going unanswered, such as:

How do I know I've found everything?
How can I stay up to date?
How can I get the source code to this library?

controlSUITE software deals with these issues by centralizing the location of software. All C2000 software is displayed and available for free download through a single website and installer.

The installer also knows the dependencies between software packages and ensures all needed components are downloaded and installed. Finally, controlSUITE software represents a way for users to stay up to date, through updates that can be set to automatically check for newer versions.

Looking to the Future
We tried to design controlSUITE such that it provided all of the content and content management required to speed design of real-time control applications, giving engineers the flexibility to develop according to their varying preferences and experience levels.

The multi-layered HAL allows users to program the MCU in the way they find most convenient. An extensive library repository reduces the time needed to develop the basics. And full application development kits speed learning and implementation. Together, we think these components create a smoother experience for programmers of all backgrounds.

Michael Wei , C2000 MCU product marketing at Texas Instruments, manages product definition and positioning, customer design engagements, business development, and customer support for the Piccolo MCU family. He also focuses on digital power conversion and HEV/EV applications. Wei received his Bachelor's in Electrical Engineering from the University of Texas at Austin with an emphasis on embedded systems and systems software.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.