Global Sources
EE Times-Asia
Stay in touch with EE Times Asia
EE Times-Asia > Processors/DSPs

Basics of ARM design on mbed IDE (Part 2)

Posted: 13 Nov 2013 ?? ?Print Version ?Bookmark and Share

Keywords:mbed? software tools? compiler? ARM? API?

There are various approaches to development in embedded systems. As noted in Part 1, with the mbed there is no software to install, and no extra development hardware needed for program download. All software tools are placed online so that you can compile and download wherever you have access to the Internet.

Notably, there is a C++ compiler and an extensive set of software libraries used to drive the peripherals. Thus, also as noted in Part 1, there is no need to write code to configure peripherals, which in some systems can be very time consuming.

BUT, although this book does not assume that you have any knowledge of C or C++, you have an advantage if you do.

The mbed Compiler and API
The mbed development environment uses the ARM RVDS (RealView Development Suite) compiler, currently Version 4.1. All features of this compiler relevant to the mbed are available through the mbed portal.

One thing that makes the mbed special is that it comes with an application programming interface (API). In brief, this is the set of programming building blocks, appearing as C++ utilities, which allow programs to be devised quickly and reliably. Therefore, we will be writing code in C or C++, but drawing on the features of the API.

Using C/C++
As just mentioned, the mbed development environment uses a C++ compiler. That means that all files will carry the .cpp (Cplusplus) extension. C, however, is a subset of C++, and is simpler to learn and apply. This is because it does not use the more advanced 'object-oriented' aspects of C++.

In general, C code will C compile on a C++ compiler, but not the other way round. C is usually the language of choice for any embedded program of low or medium complexity, so will suit us well here. For simplicity, therefore, we aim to use only C in the programs we develop. It should be recognised, however, that the mbed API is written in C++ and uses the features of that language to the full. We will aim to outline any essential features when we come to them.

Program design and structure
There are numerous challenges when tackling an embedded system design project. It is usually wise first to consider the software design structure, particularly with large and multi-functional projects. It is not possible to program all functionality into a single control loop, so the approach for breaking up code into understandable features should be well thought out. In particular, it helps to ensure that the following can be achieved:

???That code is readable, structured and documented
???That code can be tested for performance in a modular form
???That development reuses existing code utilities to keep development time short
???That code design supports multiple engineers working on a single project
???That future upgrades to code can be implemented efficiently
There are various C/C++ programming techniques that enable these design requirements to be considered, as discussed here, including: functions, flow charts, pseudocode and code reuse.

The role of functions
A function is a portion of code within a larger program. The function performs a specific task and is relatively independent of the main code. Functions can be used to manipulate data; this is particularly useful if several similar data manipulations are required in the program. Data values can be input to the function and the function can return the result to the main program. Functions, therefore, are particularly useful for coding mathematical algorithms, look-up tables and data conversions, as well as control features that may operate on a number of different parallel data streams. It is also possible to use functions with no input or output data, simply to reduce code size and to improve readability of code. Figure 1 illustrates a function call.

There are several advantages when using functions. First, a function is written once and compiled into one area of memory, irrespective of the number of times that it is called from the main program, so program memory is reduced. Functions also allow clean and manageable code to be designed, allowing software to be well structured and readable at a number of levels of abstraction. The use of functions also enables the practice of modular coding, where teams of software engineers are often required to develop large and advanced applications. Writing code with functions therefore allows one engineer to develop a particular software feature, while another engineer may take responsibility for something else.

1???2???3???4?Next Page?Last Page

Article Comments - Basics of ARM design on mbed IDE (Pa...
*? You can enter [0] more charecters.
*Verify code:


Visit Asia Webinars to learn about the latest in technology and get practical design tips.

Back to Top