Programming Embedded Systems
Introduction
The development of an embedded
system from scratch is more than just
software.
As opposed to traditional OS based
systems in which the hardware is pre-
packaged perfectly, the embedded
developer must assemble his own
hardware.
Thus errors can occur in two different
domains.
Developing software and hardware for
microcontroller based systems involves the use of
a range of tools such as code editors, assemblers,
compilers, debuggers, simulators, emulators and
programmers.
The typical microcontrollers firmware
development cycle involves:
Writing
Editing
Debugging (with the help of debugging tools, including
emulators)
Programming the microcontroller to built up a first
functional prototype of your system
DEVELOPMENT PROCESS
Processor and hardware part once chosen
remain fixed, the application firmware
have to be perfected by a number of runs
and tests.
While the cost of the processor is quite
small, the cost of developing a final
targeted system is quite high and needs a
larger time frame than the hardware
circuit design
Breakdown of the total development cost in the operating
department
The cost of software
development accounts
for 40% of total
development costs.
6
Types of targeted processors
The 32 bits era
7
Programming languages
Mainstream is
C language
8
Programs for Microprocessors
are written in 3 ways:
1. Machine code
2. Assembly language
3. High Level language examples?
• A program is written in a source editor such as _______
• Here, the user writes “source code” –this is what users
understand.
• The source code must be translated into machine code.
• This is done by a _____________.
• During the writing of source code, the user may use in
built functions of the language. These functions are stored
in __________files and ________________ files.
When a program has been written, the compiler
creates several objects from the source code.
a linker or link editor is a computer program that
takes one or more object files generated by a
compiler and combines them into a single
executable file, library file, or another object file.
Object files define symbols used in the program,
debugging information, comments and metadata.
(What is metadata??)
Its extension is usually .obj but may be something
else.
HLL or Assembly?
HLL or assembly?
HLL or assembly?
HLL or assembly?
IDEs
An IDE helps you to organise your
code and provides several
development features. It interfaces
to the compiler for you and
prevents you from having to pass
command line arguments to the
compiler yourself.
compilers
PLATFORM COMPILER
AVR AVR-GCC, AVR-G++
ARM ARM-GCC, ARM C/C++
NXP MRKIII C Compiler
Compilers are platform specific.
It is recommended that you use the official
compiler toolset from the manufacturer. But like
most open source products, open compilers are
usually the industry standard.
Debuggers
What is the use of a debugger?_________________________
They run on the development processor and support stepwise
program execution, executing one instruction and then stopping,
proceeding to the next instruction when instructed by the user.
They permit execution up to user -specified breakpoints, which are
instructions that when encountered cause the program to stop
executing. Whenever the program stops, the user can examine the
contents of various register locations or the values of variables in
use.
A good debugging capability is crucial, as today ’s programs can be
quite complex and hard to write correctly.
Device programmers download a binary
machine program from the development
processor’s memory into the target processor’s
memory.
Two types of programming exist: In –circuit and
out-of-circuit programming.
Emulators . These are used in the absence of a
physical device. An Emulator is a “virtual” target
processor on which the developer can monitor
and speculate (somewhat) accurately how the
program will run on the actual hardware. An
emulator is software.
Simulation
A simulation is a system that behaves similar to something else,
but is implemented in an entirely different way. It provides the
basic behavior of a system, but may not necessarily adhere to all
of the rules of the system being simulated. It is there to give you
an idea about how something works.
Examples
A Flight Simulator: It looks and feels like you are flying an airplane, but
you are completely disconnected from the reality of flying the plane,
and you can bend or break those rules as you see fit. For example,
you can fly an Airbus A380 upside down between London and Sydney
without breaking it.
SPICE is an electronics simulator. They model as much as possible
every detail of the target to represent what the target does in reality.
Emulation is the process of mimicking the outwardly
observable behavior to match an existing target. The
internal state of the emulation mechanism does not have
to accurately reflect the internal state of the target which it
is emulating. It adheres to all of the rules of the system
being emulated. It is effectively a complete replication of
another system but operating in a different environment to
the environment of the original emulated system.
Example
A Virtual PC emulates a PC
An android emulator emulates an android phone
Is a 3D movie a simulation or an emulation?