45/317
3 - Programming a microcontroller
3 PROGRAMMING A MICROCONTROLLER
A microcontroller is basically a programmable component. This means that it can do almost
anything, when properly programmed.
In fact, the design of the electrical schematic of a microcontroller-based application raises few
questions; the input and output pins of the microcontroller are simply connected to the binary
signals either produced or used by the external application. The designer only has to take care
to select the right pins, since some signals must be connected to special peripherals like the
Analog to Digital Converter, the Timer, etc.
It is the program that configures the pins so that they have the correct electrical behaviour, and
that processes the data to produce the appropriate response to the input signals. Since the
board will be designed with as little electronic processing as possible, all the processing is
done by software.
This produces the flexibility that is the main feature of any programmed system: unless a hard-
ware problem arises, most of the fixes and changes done to a programmed system will be
done in software.
Programming the processor is thus the key activity of the designer, the one that will take the
largest part of his time. For this reason, the use of the right tool to program the application is
critical, since program design and testing time can vary greatly according to the tools and the
language chosen.
This chapter addresses the two main issues the programmer faces: selecting the appropriate
language for the best productivity, then selecting the appropriate software tools that will allow
not only to program in that language, but also to test the program written in that language. We
will learn that an investment made prior to starting the design can prove very efficient in terms
of development time, and therefore, pay for itself.
3.1 ASSEMBLY LANGUAGE
3.1.1 When to use assembly language
Assembly language is the native language of each microprocessor. It used to be the only way
of programming a small microcontroller until high-level language compilers were made avail-
able. Programming in assembler was a job that required a lot of care and very many lines of
source code relative to the size of the application. It was justified when program memory was
small and assembly language was the only way to optimize the code size. Nowadays, micro-
controllers, except for those at the lowest-end, can afford enough memory to cope with the
code expansion factor inherent in high-level languages. Thus, for reasons explained in the fol-
lowing paragraph, a high-level language is strongly recommended and using assembly lan-
guage should not be considered except when absolutely needed.
Содержание 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 ...