Transcription of EXPLORING C FOR MICROCONTROLLERS
1 EXPLORING C FOR MICROCONTROLLERSE xploring C for MicrocontrollersA Hands on ApproachGoa UniversityIndiaVINOD G. SHELAKEK olhapur, IndiaRAJANISH K. KAMATS hivaji UniversityKolhapur, IndiaGoa UniversityIndiaJIVAN S. PARABandShivaji UniversityGOURISH M. NAIKA Catalogue record for this book is available from the Library of by Springer, Box 17, 3300 AA Dordrecht, The on acid-free paperAll Rights ReservedNo part of this work may be reproduced, stored in a retrieval system, or transmittedin any form or by any means, electronic, mechanical, photocopying, microfilming, recordingor otherwise, without written permission from the Publisher, with the exceptionof any material supplied specifically for the purpose of being enteredand executed on a computer system, for exclusive use by the purchaser of the work. 2007 Springer ISBN 978-1-4020-6066-3 (HB)ISBN 978-1-4020-6067-0 (e-book)ContentsForewordixPrefacexiiiAck nowledgmentsxvii1 MICROCONTROLLERS : Yesterday, Today, and Defining Eagle s View: MICROCONTROLLERS and Other Competing Vignettes: Microcontroller Growth The Major Players in the Microcontroller Chip Architectural Jump Starting Your First embedded System Execution of embedded System Project: Is it aGordian s Knot?
2 162 Integrated Development Getting Familiar with the Working with Keil Development Flow for the Keil IDE213 Art of c programming for Familiarizing with Your Compiler Whether to Use Headers or Not? Basic C Program Differences from ANSI C34vviContents4 EXPLORING the Capabilities of On-Chip Resources Programmingfor I/O Ports, Interrupts and Importance of Simple Ideas for Port LED Relevance of LEDs in Today s Lightening Different Programs for LED More Projects on LED Interfacing to Running Running Bicolor Interfacing 6 LEDsUsing 3 Microcontroller Pins The LED Dimmer Fading RGB LED Moving DIP Switch Interfacing: Getting Input to YourEmbedded LCD Interrupts in Writing ISRs in A Word about Interrupt Latency635 Hyperterminal-Based Packet-based Control Mechanism and Lots of Application 1: Packet-based Interface for Application 2: Packet-based Interface for StepperMotor Application 3: Home Automation from PC HyperTerminal786 Embedding Microcontroller in Routine Application 1.
3 Podium Application 2: Front Desk Application 3: Cafeteria Food Alert/Microcontroller-basedMenu Application 4: Chimney Application 5: Who s First Application 6: Counting Application 7: Anonymous Energy Efficient Lighting Using Microcontroller1197 Microcontroller-based Measurement and Control Application 1: Reading a PWM Waveform Single Set-point On/Off Application 3:I2 CInterface with Serial EPROM1338 Securing Your embedded System Security Challenges in embedded Application 1: Authentication for Your EmbeddedSystem Application 2: Timeout Waiting for Input Data144 References151 Index155 ForewordIf we accept the premise that an embedded engineer is made ratherthan born, then how does one go about making a good one? The authorsof this bookExploring C for MICROCONTROLLERS : A Hands-on Approacharecertainly good ones . Not only do they explore some of the influencesthat shaped themselves but they also try to shape would-be embeddedengineers.
4 Research and developmental activities in embedded systemshas grown in a significant proportion in the recent past. embedded soft-ware design is not new to the world, but with the changing time, ithas gained considerable momentum in the recent past, and many youngengineers are strongly inclined to pursue their future in this field. Thebook is mainly targeted to these engineers who would like to understandin great depth the synergetic combination of hardware and book is divided into eight chapters. Chapter 1 introduces a briefbackground about micro-controllers and explains how they are embed-ded into products commercially available in the market to emphasize theimportance of these in the daily life of mankind. It also gives an insightinto the architectural details and embedded system concepts for stu-dents projects to motivate them into this exciting field. The rest of thebook concentrates on software development.
5 The integrated developmentenvironment (IDE) is introduced in Chapter 2. Again the screen shotsand step-by-step procedure will certainly make the students and engi-neers fully understand the development process. Chapter 3 differenti-ates the embedded C paradigm from the conventional ANSI C. Againthe authors explain how to successfully overcome the memory and timeconstraints while developing an embedded C program. Chapter 4 givesan overview of program development for on-chip resources for MCS51family of MICROCONTROLLERS . Chapters 5 8 are devoted to live case book has come out with an elegant presentation to aspiringstudents and engineers from the teaching experience and technicalknowledge the authors have put over a long time in this field. I stronglyrecommend this book for intermediate programmers, electronics, electri-cal, instrumentation engineers or any individual who is strongly inclinedixxForewordto take up his or her career in embedded c programming .
6 I am sure thereader will experience learning embedded programming by example andlearning by doing. Last but not the least, this book will certainly be avalue addition to the world of embedded Quality EvaluationNational Remote Sensing AgencyDepartment of SpaceGovernment of IndiaDr. Senthil Kumar is Head of DQE and PQCD sections of NationalRemote Sensing Agency (NRSA) an autonomous operational centerunder Department of Space (DOS), Government of India. This is thenodal agency in the country for receiving, processing, and distributingthe satellite and aerial remote sensing data and products. NRSA is alsoresponsible for providing end-to-end solutions for utilization of datafor geospatial applications and information services. NRSA has a hugearchive of remote sensing data acquired through Indian and foreignsatellites and also has the capability to acquire data pertaining to anypart of the globe on demand.
7 It is one of the important centers forpromotion of remote sensing and geographic information system tech-nologies in India. NRSA has set up satellite data processing facilitiesstarting from data reception to utilization at various centers withinIndia and across the past few decades have witnessed evolution of have revitalized a number of products or equipment in almost allfields including telecommunications, medical, industrial, and consumerproducts. These embedded microcontroller systems now resides at theheart of modern life with a variety of applications in fields like con-sumer electronics, automotive systems, domestic, and even in aerospaceproducts. Embedding a microcontroller in an electronics instrument orproduct requires a specialized design skill which requires a synergy ofhardware and software our day-to-day life we come across a number of embedded we switch on the washing machine or send an SMS on a cell phoneone cannot prevent without thinking the mechanism and the co-workingof hardware and software in the background.
8 The market for such smartembedded products is occupying newer and newer applications seem-ingly impossible few years back. Last year the IDC, a premier globalmarket intelligence firm, revealed that the embedded industry productdevelopment was expected to be as high as $75 billion. This entails theindustry requirement of trained human resource with mixed skill setboth in hardware and software. Unfortunately the synergetic demandof hardware and software or sometimes even referred to as firmwarecompetency has led to a supply demand gap of HR in this field. Thisgap expressed in numerical figures led to requirement of around 150,000embedded engineers to serve the global embedded industry. This bookis ideal for all those who would like to pursue their career in the excitingworld of microcontroller-based embedded systems. The approach is ped-agogical; first the hardware module is presented and then the associatedsoftware code in Keil hardware designed is useful for engineering graduates and prac-ticing professionals with the required knowledge and practical hands onskills to design with embedded systems.
9 However, the prerequisite forthe book is background of theoretical aspects of architecture of micro-controllers especially the MCS-51 family. The book starts with initialxixiiPrefaceexperiments, which provide familiarization with the capabilities and thelimitations of the basic 8051 microcontroller using a simulator. Once thereader is comfortable with these primitive programs which covers almostall the on-chip resources, he or she can switch to more advanced Scope of the BookWe now review the topics covered in sequence, chapter by 1 provides an overview of MICROCONTROLLERS and their appli-cations in different domains. The architectural trends and the growtheconomics emphasizes the importance of the subject. The photograph ofthe setup and the hints toward project execution will definitely boost theconfidence of the novice to kick-start the project with minimal 2 is devoted to the IDE for the MCS-51 family.
10 The simulationand single stepping as described in this chapter will solve all the projectintricacies of the readers. Chapter 3 illustrates the basic difference intraditional c programming and embedded C. Chapter 4 deals with theprogramming of on-chip resources of MCS-51 family microcontrollersin C. The theoretical details of these on-chip resources such as ports,timers, etc., are completely eliminated. As the book aims at hands-onapproach, the programs for the on-chip resources have been developedand their execution is illustrated in the Keil simulation last four chapters, , 5 8 deal with various project case stud-ies. Several case studies in various application domains such as lighting,measurement and control, security, and domestic applications are devel-oped from scratch. The hardware and software developed in the form ofcase studies also caters to a set of mini projects, which are discussed indetail from the design phase to the actual implementation on a targetsystem.