Example: marketing

Embedded C - Naresuan University

Embedded C8322 Prelims (i-xvi) 25/2/02 3:04 pm Page i8322 Prelims (i-xvi) 25/2/02 3:04 pm Page iiEmbedded CMichael J. PontAn imprint of Pearson EducationLondon Boston Indianapolis New York Mexico City TorontoSydney Tokyo Singapore Hong Kong Cape Town New DelhiMadrid Paris Amsterdam Munich Milan Stockholm 8322 Prelims (i-xvi) 25/2/02 3:04 pm Page iiiPEARSON EDUCATION LIMITEDHead Office:London Office:Edinburgh Gate128 Long Acre Harlow CM20 2 JELondon WC2E 9 ANTel: +44 (0)1279 623623 Tel: +44 (0)20 7447 2000 Fax: +44 (0)1279 431059 Fax: +44 (0)20 7240 5771 Websites: published in Great Britain in 2002 Pearson Education Limited 2002 The right of Michael J. Pont to be identified as Author of this Work has been asserted by him in accordance with the Copyright, Designs and Patents Act 0 201 79523 X British Library Cataloguing in Publication DataA CIP catalogue record for this book can be obtained from the British LibraryLibrary of Congress-in-Publication DataPont, Michael C/Michael J.

1 Programming embedded systems in C 1 1.1 Introduction 1 1.2 What is an embedded system? 1 1.3 Which processor should you use? 2 1.4 Which programming language should youuse? 7 1.5 Which operating system should you use? 9 1.6 How do you develop embedded software? 12 1.7 Conclusions 15 2 Introducing the 8051 microcontroller family 17 2.1 ...

Tags:

  Programming, Embedded, Embedded programming

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Embedded C - Naresuan University

1 Embedded C8322 Prelims (i-xvi) 25/2/02 3:04 pm Page i8322 Prelims (i-xvi) 25/2/02 3:04 pm Page iiEmbedded CMichael J. PontAn imprint of Pearson EducationLondon Boston Indianapolis New York Mexico City TorontoSydney Tokyo Singapore Hong Kong Cape Town New DelhiMadrid Paris Amsterdam Munich Milan Stockholm 8322 Prelims (i-xvi) 25/2/02 3:04 pm Page iiiPEARSON EDUCATION LIMITEDHead Office:London Office:Edinburgh Gate128 Long Acre Harlow CM20 2 JELondon WC2E 9 ANTel: +44 (0)1279 623623 Tel: +44 (0)20 7447 2000 Fax: +44 (0)1279 431059 Fax: +44 (0)20 7240 5771 Websites: published in Great Britain in 2002 Pearson Education Limited 2002 The right of Michael J. Pont to be identified as Author of this Work has been asserted by him in accordance with the Copyright, Designs and Patents Act 0 201 79523 X British Library Cataloguing in Publication DataA CIP catalogue record for this book can be obtained from the British LibraryLibrary of Congress-in-Publication DataPont, Michael C/Michael J.

2 Bibliographical references and 0-201-79523-X (pbx. : alk. paper) (Computer program language) 2. Embedded computer systems--Design andconstruction. I. P65 rights reserved; no part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without either the prior written permission of the Publishers or a licence permitting restricted copying in the United Kingdom issued by the Copyright Licensing Agency Ltd, 90 Tottenham Court Road, London W1P 0LP. This book may not be lent, resold, hired out or otherwise disposed of by way of trade in any form of binding or cover other than that in which it is published, without the prior consent of the programs in this book have been included for their instructional value. The publisher does not offer any warranties or representations in respect of their fitness for a particular purpose, nor does the publisher accept any liability for any loss or damage arising from their of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks.

3 Pearson Education Limited has made every attempt to supply trademark information about manufacturers and their products mentioned in this book. The publishers wish to thank Infineon Technologies for permission to reproduce the material in Figure 9 8 7 6 5 4 3 2 1 Designed by Claire Brodmann Book Designs, Lichfield, StaffsTypeset by Pantek Arts Ltd, Maidstone, KentPrinted and bound in Great Britain by Biddles Ltd of Guildford and King s LynnThe Publisher s policy is to use paper manufactured from sutainable Prelims (i-xvi) 25/2/02 3:04 pm Page ivThis book is dedicated to Sarah8322 Prelims (i-xvi) 25/2/02 3:04 pm Page vMichael J. Pontis an experienced software engineer who began his first embeddedproject in 1986. Since then he has lectured and carried out research at theUniversity of Sheffield and the University of Leicester, and has provided consul-tancy and training services to a range of international companies.

4 Michael is theauthor of two previous books Patterns for Time-Triggered Embedded SystemsandSoftware Engineering with C++ and CASE author8322 Prelims (i-xvi) 25/2/02 3:04 pm Page viPrefacexi1 programming Embedded systems in What is an Embedded system? Which processor should you use? Which programming language should youuse? Which operating system should you use? How do you develop Embedded software? Conclusions152 Introducing the 8051 microcontroller s in a name? external interface of the Standard frequency and Serial Power Conclusions343 Hello, Embedded Installing the Keil software and loading the project36 Contents8322 Prelims (i-xvi) 25/2/02 3:04 pm Page Configuring the Building the Running the Dissecting the Aside: Building the Conclusions564 Reading techniques for reading from port : Reading and writing : Reading and writing bits (simple version) : Reading and writing bits (generic version) need for pull-up with switch : Reading switch inputs (basic code) : Counting Conclusions805 Adding structure to your Object-oriented programming with The Project Header ( ) The Port Header ( ) Example: Restructuring the Hello Embedded World Example.

5 Restructuring the goat-counting Further Conclusions1116 Meeting real-time Creating hardware delays using Timer 0 and Timer Example: Generating a precise 50 ms delay1208322 Prelims (i-xvi) 25/2/02 3:04 pm Page : Creating a portable hardware not use Timer 2? need for timeout loop : Testing loop : A more reliable switch Creating hardware Example: Testing a hardware Conclusions1427 Creating an Embedded operating The basis of a simple Embedded Introducing Using Timer 0 or Timer Is this approach portable? Alternative system Important design considerations when using Example: Milk Conclusions1878 Multi-state systems and function Implementing a Multi-State (Timed) Example: Traffic light Example: Animatronic Implementing a Multi-State (Input/Timed) Example: Controller for a washing Conclusions2159 Using the serial What is RS-232?

6 Does RS-232 still matter?2188322 Prelims (i-xvi) 25/2/02 3:04 pm Page basic RS-232 data transmission and baud software the on-chip UART for RS-232 Example: Displaying elapsed time on a The Serial-Menu Example: Data Example: Remote-control Conclusions25310 Case study: Intruder alarm The software Key software components used in this Running the The Conclusions28311 Where do we go from Have we achieved our aims? Suggestions for further for Time-Triggered Embedded Operating Conclusions289 Index291 Licensing Agreement295xContents8322 Prelims (i-xvi) 25/2/02 3:04 pm Page xThis book provides a hardware-free introduction to Embedded software forpeople who: Already know how to write software for desktop computer systems. Are familiar with a C-based language (Java, C++ or C).

7 Want to learn how C is used in practical Embedded remainder of this preface attempts to answer some questions which prospec-tive readers may have about the What is an Embedded system?As far as this book is concerned:This type of Embedded system is all around us. Use of Embedded processors in pas-senger cars, mobile phones, medical equipment, aerospace systems and defencesystems is widespread, and even everyday domestic appliances such as dishwash-ers, televisions, washing machines and video recorders now include at least onesuch What type of processor is discussed?This book focuses on the Embedded systems based on the 8051 family of microcon-trollers. Prices for 8051 devices start at less than $ (US). At this price, you get aperformance of around 1 million instructions per second, and 256 bytes(notmegabytes!) of on-chip RAM.

8 The 8051 s profile (price, performance, availablememory) matches the needs of many Embedded systems very well. As a result, thePrefaceAn Embedded system is an application that contains at least one programmablecomputer (typically in the form of a microcontroller, a microprocessor or digitalsignal processor chip) and which is used by individuals who are, in the main,unaware that the system is Prelims (i-xvi) 25/2/02 3:04 pm Page xixiiPreface8051 architecture originally developed by Intel is now implemented in more than400 chips; these are produced by a diverse range of companies including Philips,Infineon, Atmel and Dallas. Sales of this vast family are estimated to have the largestshare (around 60%) of the microcontroller market as a whole, and to make up morethan 50% of the 8-bit microcontroller market. Versions of the 8051 are currently usedin a long list of Embedded products, from automotive systems to children s low cost, huge range, easy availability and widespread use of the 8051family makes it an excellent platform for developing Embedded systems: thesesame factors also make it an ideal platform for learningabout Embedded you will subsequently use 8-, 16- or 32-bit Embedded processors, learningto work within the performance and memory limits of devices such as the 8051 isa crucial requirement in the cost-conscious Embedded market.

9 You simply cannotacquire these skills by developing code for a Pentium (or similar) Which operating system is used?The 256 bytes of memory in the 8051 are of course insufficient to support any ver-sion of Windows, Linux or similar desktop operating systems. Instead, we will describehow to create your own simple Embedded operating system (see Chapter 7). This do-it-yourself approach is typical in small Embedded applications, where the memoryrequirements and expense of a desktop operating system (like Windows or Linux) or ofa so-called real-time operating system simply cannot be justified. However, theapproach is also in widespread use in large Embedded systems (for example, aerospaceapplications or X-by-wire systems in the automotive industry), where conventionaloperating systems are generally considered to be too to work on a naked processor and create your own operating system arekey requirements for software developers wishing to work with Embedded What type of system is discussed?

10 This book presents a number of examples adapted from working Embedded sys-tems. These include: A remotely-controlled robot. A traffic-light sequencer. A system for monitoring liquid flow rates. A controller for a domestic washing Prelims (i-xvi) 25/2/02 3:04 pm Page xiixiiiPreface An animatronic dinosaur. A general-purpose data acquisition and other examples are used to illustrate key software architectures that arein widespread use in Embedded designs; the examples may be adapted andextended to match the needs of your own book concludes with a final case study: this brings together all of the fea-tures discussed in earlier chapters in order to create an intruder alarm system. Thiscase study includes the following key components: A suitable Embedded operating system. A multi-state system framework. Software to process the inputs from door and window sensors.


Related search queries