http://www.esacademy.com/automation/docs/c51primer/c51prim.htmC51 PrimerHTML version by
Steffen Duffner, Irena & Olaf Pfeiffer
Last modified on 03/03/96. Click here for the Table of ContentsAbout The C51 PrimerIf you've flicked through this publication, you may be left thinking that it is necessary to be an expert to produce workable programs with C51. Nothing could be further from the truth. It is perfectly possible to write real commercial programs with nothing more than a reasonable knowledge of the ANSI C language.
However, to get the maximum performance from the 8051, knowing a few tricks is very useful. This is particularly true if you are working on a very cost-sensitive project where needing a bigger RAM or EPROM can result in an unacceptable on-cost. After all, if cost was not a consideration, we would all be using 80C166s and 68000s!
Whilst the C51 Primer is really aimed at users of the Keil C51 Compiler, it is applicable in part to other compilers. However, some compilers do not allow such low-level access and have fewer 8051-specific extensions. They are less likely to be used on projects where getting maximum performance is essential.
The C51 Primer Will Help You - Find your way around the basic 8051 architecture.
- Make a sensible choice of memory model and special things to watch out for.
- Locate things at specific addresses.
- Make best use of structures.
- Use bit-addressable memory.
- Think in terms of chars rather than ints.
- Get the best out of the various pointer types.
- Get a modular structure into programs.
- Access on and off-chip ports and peripherals.
- Deal with interrupts.
- Use registerbanks.
- Deal with the stack.
- Understand RAM overlaying.
- Interface to assembler code.
- Use special versions like the 80C517 and 87C751.
- Use assembler tricks in C.
- Help the optimiser to produce the smallest, fastest code.
The C51 Primer Will Not Help You- Program in ANSI C - get a good reference like Kernighan & Ritchie.
- Write portable code - simply use the compiler without using any extensions.
- Set-up each and every on-chip peripheral on all of the 90 different 8051 variants! Some are, however, covered in the appendices.
This guide should be read in association with a good C reference such as Kernighan and Ritchie and is not meant to be a definitive work on the C language. It covers all the 8051-specific language extensions and those areas where the CPU architecture h as an impact on coding approach.
|