Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
C51 Primer

C51 Primer

Ratings:

5.0

(1)
|Views: 120|Likes:
Published by api-3834005

More info:

Published by: api-3834005 on Oct 18, 2008
Copyright:Attribution Non-commercial

Availability:

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

03/18/2014

pdf

text

original

An Introduction To The Use Of The Keil
C51 Compiler On The 8051 Family
Edition 3.6 05 October 2003
by
Mike Beach
Editor for Edition 3.6
Chris Hills
Hitex (UK) Ltd.

Tel +44 24 7669 2066
Fax: +44 24 7669 2131
www.hitex.co.uk

C51 Primer
Chris
Hills

Digitally signed by Chris
Hills
DN: CN = Chris Hills, C =
GB, O = Phaedrus
systems, OU = Phaedrus
Systems
Reason: I am the author
of this document
Location: Tamworth UK
Date: 2003.10.05
19:23:35 +01'00'

\u00a9 Copyright Hitex (UK) Ltd. 1996, 2002
& Phaedrus Systems 2002,2003
All Rights Reserved.
No Part of this publication may be transmitted, transcribed, stored in a retrieval system, translated into any language,

in any form, by any means without the written permission of Hitex (UK) Ltd.
www.hitex.co.uk
page 2 of 190
Version 3.5
Contents
0
About The C51 Primer...................................................................................................... 7
0.1 History............................................................................................................................ 8
1
Introduction.................................................................................................................... 11
2
Compiler Chain.............................................................................................................. 13
3

C51 Basics - The 8051 Architecture................................................................................. 15
3.1 8051 Memory Configurations........................................................................................ 15
3.1.1 Physical Location Of The Memory Spaces............................................................... 15
3.2 Hardware Memory Models........................................................................................... 19

3.2.1 External DATA....................................................................................................... 19

3.2.2 External Code........................................................................................................ 20
3.2.3 Write to CODE Space............................................................................................ 20
3.3 Possible Memory Models............................................................................................. 21
3.3.1 ROM Memory Models............................................................................................. 21
3.3.2 RAM Memory Models............................................................................................. 22
3.3.3 Choosing The Best Memory Configuration/Model.................................................. 23
3.3.4 What data goes where?.......................................................................................... 25
3.4 Setting The Memory Model........................................................................................... 26
3.5 Local Memory Model Specification............................................................................... 27
3.5.1 Overview............................................................................................................... 27

4

Declaring Variables And Constants................................................................................ 29
4.1 Constants...................................................................................................................... 29
4.2 Variables...................................................................................................................... 30
4.2.1 Uninitialised Variables........................................................................................... 30
4.2.2 Initialised Variables............................................................................................... 31
4.3 Watchdogs With Large Amounts Of Initialised Data...................................................... 32
4.4 C51 Variables............................................................................................................... 33
4.4.1 Variable Types....................................................................................................... 33
4.4.2 Special Function Bits............................................................................................... 35
4.4.3 Converting Between Types.................................................................................... 36
4.4.4 A Non-ISO Approach To Checking Data Type Overflow......................................... 37

5

Program Structure And Layout........................................................................................ 39
5.1 Modular Programming In C51...................................................................................... 39
5.2 Accessibility Of Variables In Modular Programs.......................................................... 42
5.3 Building a C51 Modular Program................................................................................. 45
5.3.1 The Problem........................................................................................................... 45
5.3.2 Maintainable Inter-Module Links............................................................................ 45
5.4 Standard Templates (and Version Control)................................................................... 51
5.4.1 Version Control...................................................................................................... 51
5.5 Task Scheduling........................................................................................................... 52
5.5.1 Applications Overview........................................................................................... 52
5.5.2 Simple 8051 multi-task Systems.............................................................................. 53
5.5.3 Simple Scheduling - A Partial Solution.................................................................... 55

6

C Language Extensions For 8051 Programming.............................................................. 57
6.1 Accessing 8051 On-Chip Peripherals........................................................................... 57
6.2 Interrupts...................................................................................................................... 58
6.2.1 The Interrupt Function Type................................................................................... 58
6.2.2 Using C51 With Target Monitor Debuggers............................................................ 58
6.2.3 Coping Interrupt Spacings Other Than 8................................................................ 59

7
Pointers In C51............................................................................................................... 61
7.1 Using Pointers And Arrays In C51................................................................................. 61
www.hitex.co.uk
page 3 of 190
Version 3.5

Activity (5)

You've already reviewed this. Edit your review.
1 hundred reads
gautam_reddys liked this
ksahara liked this
kr0465 liked this
sdfsdfsdfsdfsdfa liked this

You're Reading a Free Preview

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