226/317
8 - C Language and the C Compiler
8.3 USING THE C COMPILER
It is not the purpose of this book to teach the basics of C language. The reader is expected to
have had some introduction to the C language, even if he is not an expert; but some experi-
ence is required to appreciate the specific features of C programming for the ST7.
When programming in C for a microcontroller, the following points must be taken into account:
Memory allocation
Initialization of variables
Inputs and outputs
Interrupt handling
Limitations put on the full implementation of the C language
These points will be detailed here. The C language will be used in the applications described
in the next chapters, and you will see how easy it is to write an application program using C
language compared to assembler.
8.3.1 Memory allocation
In a microcontroller, the program is stored in ROM and variables are stored in RAM, as every-
body knows. This means that you must take care to specify, for the development tools, the ad-
dresses in memory of ROM and RAM, so that the linker puts the right things in the right place.
This is not required when programming in C for example for a PC: the development chain de-
cides by itself where to allocate everything, the program works, and there is no need to worry.
The final allocation of memory is performed at the linker level. The linker parameter file con-
tains the information for the linker to place the various segments at the appropriate addresses.
This file must of course match the memory map of the type of microcontroller chosen.
In most cases, no special care must be taken at the C language source level. By default, the
compiler allocates all the code and the initial values of the variable in segments that will be
placed in ROM, while the data storage is placed in segments that will be placed in RAM.
Содержание 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 ...