46/317
3 - Programming a microcontroller
There are, in almost all applications, parts of the code that still require assembly programming.
These parts are, most of the time, small but have an important impact on the program. Here
are a few such cases:
The initialization part of the program. All high-level languages provide for initialization of the
core and the memory. However, the basic organisation of the memory (address of the ROM
and the RAM, reset and interrupt vectors) and a few other kinds of initialization are supplied
as an assembly-language template, that has to be adapted to suit the actual application.
Some interrupt service routines that require very fast processing.
Some repetitive functions that are frequently invoked and whose optimization in terms of
speed has an important impact on the performance of the whole program.
The third case implies that the programmer carefully reads the implementation chapter of his
compiler's manual. The way arguments and return values are passed back and forth are spe-
cific to each compiler. Failure to comply with these conventions will prevent the assembly
code from working.
3.1.2 Development process in assembly language
The development of a program consists of three main phases: analyzing, writing the code, de-
bugging. In other words, the successive phases can be described as follows:
The first phase is when the programmer defines what the program should do. This is only
paperwork, even if it is done using a computer and a word processor or a spreadsheet. This
phase defines the main program blocks, the data inputs and outputs, the storage, and some
of the algorithms.
The second phase is the translation of the first one into the chosen computer language. The
result of it is the source code and a few files that drive the various programming tools. The
tools used in this phase are the text editor, to type and amend the source code, and the
assembler and the linker to check its syntactic correctness. The Make utility is also a
convenient tool, that helps keeping the program up-to-date, when any of its parts have been
changed, by processing only the changed source files.
The third phase consists of all that is needed to make the source code work. It involves
removing all programming errors, that is, the flaws in the first and second phases related to
logic, coordination, and data management. This third phase is by far the most difficult and
requires the most development time. The tools used, the Simulator and In-Circuit Emulator,
have to be very powerful because many errors are difficult to find.
When the program is fully functional, it is often stored in an EPROM that is either external, or
as in the ST7, internal to the microcontroller. This produces a prototype of the microcontroller
that must be extensively tested before being launched to production, especially if, for large
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...