Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Writing C Code for the 8051

Writing C Code for the 8051

|Views: 2,422|Likes:
Published by BHUSHAN
to program the ebedded microcontroller 8051 using c,c++
to program the ebedded microcontroller 8051 using c,c++

More info:

Published by: BHUSHAN on Aug 29, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





Writing C Code for the8051
About the Keil Compiler
Keil Software (http://www.keil.com) publishes one of the most completedevelopment tool suites for 8051 software, which is used throughoutindustry. For development of C code, their Developer's Kit productincludes their C51 compiler, as well as an integrated 8051 simulator fordebugging. A demonstration version of this product is available ontheir website, but it includes several limitations (seenext section). Thisis the software that will be used for CECS-347.
 The C programming language was designed for computers, though,and not embedded systems. It does not support direct access toregisters, nor does it allow for the reading and setting of single bits,two very important requirements for 8051 software. In addition, mostsoftware developers are accustomed to writing programs that will byexecuted by an operating system, which provides system calls theprogram may use to access the hardware. However, much code for the8051 is written for direct use on the processor, without an operatingsystem. To support this, the Keil compiler has added several extensionsto the C language to replace what might have normally beenimplemented in a system call, such as the connecting of interrupthandlers. The purpose of this manual is to further explain the limitations of theKeil compiler, the modifications it has made to the C language, andhow to account for these in developing software for the 8051 microcontroller.
Keil Limitations
 There are several very important limitations in the evaluation versionof Keil's Developer's Kit that users need be aware of when writingsoftware for the 8051.
Object code must be less than 2 Kbytes
 The compiler will compile any-sized source code file, but the finalobject code may not exceed 2 Kbytes. If it does, the linker will refuse tocreate a final binary executable (or HEX file) from it. Along the samelines, the debugger will refuse any files that are over 2Kbytes, even if they were compiled using a different software package.Few student projects will cross this 2Kbyte threshold, but programmersshould be aware of it to understand why code may no longer compilewhen the project grows too large.
Program code starts at address 0x4000
All C code compiled and linked using the Keil tools will begin at address0x4000 in code memory. Such code may not be programmed intodevices with less than 16Kbytes of Read-Only Memory. Code written inassembly may circumvent this limitation by using the "origin" keywordto set the start to address 0x0000. No such work-around exists for Cprograms, though. However, the integrated debugger in the evaluationsoftware may still be used for testing code. Once tested, the code may
be compiled by the full version of the Keil software, or by anothercompiler that supports the C extensions used by Keil.
C Modifications
 The Keil C compiler has made some modifications to an otherwiseANSI-compliant implementation of the C programming language. Thesemodifications were made solely to facilitate the use of a higher-levellanguage like C for writing programs on micro controllers.
Variable Types
 The Keil C compiler supports most C variable types and adds several of its own.
Standard Types
 The evaluation version of the Keil C compiler supports the standardANSI C variable types, with the exception of the floating-point types. These types are summarized below.
char81-128 to +127unsigned char810 to 255enum162-32,768 to +32,767short162-32,768 to +32,767unsigned short1620 to 65,535int162-32,768 to +32,767unsigned int1620 to 65,535long324-2,147,483,648 to+2,147,483,647unsigned long3240 to 4,294,697,295
In addition to these variable types, the compiler also supports the
data structures, as well as type redefinition using
Keil Types

Activity (25)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
frcrce08 liked this
phantienvuong liked this
satish2812 liked this
zoltrix15 liked this
eimc2 liked this
Subin Subhagan liked this
fajar34 liked this
radioman_2 liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->