Вы находитесь на странице: 1из 348
Embedded Systems Architecture, Pragramming and Design Second Edition Raj Kamal Acknowledgements um money grate my teaches: a the din Iu of Tesbneogy, Dei (1966-72) and the Univrsty of pps, Sweden (1978-79, 198), Tor eahing ne the impenance of searing and theese of Keep ‘rere techn. {would Fhe oth Pok MS Seb. FNA. for his support and blesings ioghoat my scaemic Ie ckoowedgr ny Inder coleaues -D: PC Sharma, Dr?K Chante, Dr Sajee Tolar, Mos Win Tek. Dr A “Snomt, De Maya ng. Dr Sanjay Tawar, Ms Prot Sakon, Ms Sada Masih Ms Apuma Dev, and Ms Vat G “Tearand eter nies seaman, Dr PS Grover Det). De Harvie Singh Sani (Hyderaba), De Radka SGutipauey Dr TV Gopl (Anna Uniersiy) and Dr KM Mea (Annu Univesity)—fr tc constant encourage oeiation of my efits. ar thal to heel ean t MeCeaw ill Edin nda Fortec eviews rd day tect, Lacon ne college Dr MK Sa, Hea. Conger Cre of the Universi. wh wi is ew etion she posed aay dig he as phase ofthe pregrain of his ook, Tool alo ike otha all those viewers who Took ou ie ogo tough the rit and give mete Fendbck, mame re itd belo Ramanaryan Rody sep of Computer Science ond Enginern. te Gandia of Technology He Delhi lita Folare findstan Clee of Sone end Tchelogs. Agra Akhil Kothart dep of Electonics and Conmatiation Engineering ahaa Sin Des Tait of Te: Gar priya Kear ins Isat of Engincerag and eral, imi Adina dep of Ceci oe) Commute and Ergineein ‘uta instina of Engivering we Monee Kola Pipankar Ghosh dep of Elec nd Commanicaton Engineering “Sal Ist of Teta. Roan ehashish De dep af Elecrnnics end Cominco Engineering eahnad Saha ning of Tecate: Kote Finally, F acknowledge my wife, Sisil Mtl and my Family merbecs—Shalin Mita, Necdbi Mital, De At ‘ondskar Dr hip! Konasar and Me Anh Kondaskar—for thee immense love, understanding and sopping Je wong ofthis eee eden P Kabisapathy Dep of Eleconics cn Inaramenaion Engineering, College of Enginering and Tecnology. Bhubaneswar KK Mohapatra Dept of Elecinnic. Neti nttatofTetnolos, Rowe JK Meadiratta Dept ef Electrics and Communication ond Engineering RY. Cale of Eninering.Bangaine la B Das ‘ep of Electronics Engineering National Insite of Tecan Calicut ‘Santa Kumari Dept Feces and Canvnonicaton Engineering “anv Universi, Vb V Mortidharen Dept Commuter Sconce ond Bnei. MS Rone hotioneof Toole, Banglore Josephine P Kumar Dept of Computer Science and Brine. MUI Coleg of Enginecring. Bangalore Stanley Johnson Invense Ina Pt. Lid. Cheoma ro with K Contents Prec tothe Second Edition Prac othe Fist Edition 1. Intraductin to Embedded Systems THE Embedded Systems 12 Presi Eade in 2 System 5 13 Embedded Hardware Units and Devices in Spc 10 14 Embed Soma in a Sytem 19 15 Examples of Emedod Sysem 27 16 Embed Steno chip (Se) and Use of VESI Cit Design Texhaology 29 17 Compler yes Desig al Process 12 [LF Design Process in Entel Spey 17 19 omalzaion of System Design 42 1.10 Design Proves nd Design Examples 43 LIF Clasifiton of Embeoled Systeme 52 12 Skis Reqbired orn bedded Systm Desisner 38 2. $051 and Advanced Proceso Architectures, Memory Organization and Real-world Intrtacing 2I BSI Accent 62 22 Real World nertaing 72 2.3 Inradcton to Adve Archean 214 Procesor and Memory Orpnizaian 25 racion-Level Plea 10 26 Perormance Mees 106, 2.7 Memory Types, Memory-Maps and Adress 105 2.8 Proceuor Slostion 12! 29 Memory Seen 118 5, Device and Communication Bases for Devices Network RI 1O Types and Bam 120 42 Sor Communion Devices 1 43 Parl Device Pons 14 1A SopbistsedItrtacng Fetus in Device ns 150 35. Wels Devies 15! 36 Timer nd Counting Devies 152 47 Welcog Tiree 157 38 Rel Time Cook 139 519 Networked Embed Syoms 139 310 Saial Bus Communion Protea 160 2LI Paral Bs Device role Parallel Communication Network Using ISA. PC, POLX a Advanced Buses (66 412 Inert Enabled Syren Network Prtacls 170 413. Wireless nd Motil Sytem Protocols 175 Device Drivers and Interrupts Service Mechanism ‘$1 Prgms 0 Busywcit Apeeach witout Inert Service Mechanism 189 a ro xiv 42 ISR Concene 192 5 ncrpt Sources 200 413 nrg Servicing (Huang) Mechanim 203 415. Moliple Incr 209 “6 Comex and the Periads for Cote! Switching, Inter Latency and Deane 211 449 Clasiticaton of Process lnterrupt Service Mechanism frm Content Saving Angle 27 444 Drea Memory Aeces 218 49 Device Driver Programming 220 Programming Concepts and Erabeded Programming in C, + and Java 5.1 Sofware Programing in Assembly Language (ALP) sad in High-Level Lingwage “C235 5.2 C Program Elements: Header and Source File and PeporesorDietves 237 53. Program Elements: Macros and Functions 259, 514 Program Element: Data Types, Duta Stucures, Motes Sttemens Lops and Poiners 247 55 Object.Orented Programming 262 56 Embedded Programming in Cr 265, 57 Embosded Progamming in fava 261 (Program Medelinn Concepts 6.1 Progr Models 274 62 DEG Moses 277 3. Ste Machine Programming Models for Event conralled Popa Flow 282 {64 Modeling of Multiprocessor Systems 258 65 UML Modeling 295 2. Interprocess Commnication and Synchronization of Processes, Threads and Tasks LL Muliple Preset an Appicaion 05 72. Maliple Teas in am Applicaton 306 73 Tasks 308 14 Tank Sates 08 15 Tank and Data 310 “16. Cleareut Distinction teoween Farsi, ISRS and Tanks y ther Characterisies 377 17 Concept of Semaphore 314 18 Shared Dats 325 118 Inerpacese Commusicaion 230 1140 Signal Fanction 332 TN Semaphoce Functions 324 LAD Message Queue Fares 35 7113. Mailbox Functions 337 ZLIA Pipe Functions. 339 LAS Sooke: Furctions 347 716, RPC Functions 45 8. Real-Time Operating Systems 8:1 OS Services 351 82 Process Management 355 83 Timer Functions 356 8 Event Funcions 258 85 Memory Management 258 Contents ms 380 contents ‘56 Devic. Fle and 10 Subyysems Management 67 17 loterspt Roane n RTOS Environment eu Handling of reap Sas Call 1 Keattime Oporating Spwens 70 9 Basie Design Using an RTOS 372 10 Rugs Tas Scheduling Modes, tterap Latency and Resp of the Tasks Perfomance Metics 385 LIL OS Seouiy Funes OP 9. Realtime Operating System Progeamming-1: MicrogOS.I and VaWorks 91 Basic Fusions and Types of RTOSES. 408 92 RTOS mcOs-t #10 93 RTOS VaWorks 453 10. Reals Operitng System Programming: Windows CE, OSEK and Rea time ux Functions 11 Windows CE 78 102 OSEK 494 103 Linws 26.cand RTLnox 496 1H. Design Examples and Case Studies of Program Modeling and Programming with RTOS 11.1 Case Study of Embed System Design ad Cocing fo an Amati 5/2 (Chole Verding Machine (ACVM) Using Mocs RTOS 1.2 Case Stay of Digial Camers Harbrre at Solvare Arciecre 531 113 Case Sua of Coin fr Seating Appicaion Layer Byte Sueur on 3 TTCHMP Nevwork Using RTOS Vawerks 57 12. Design Examples and Cae Stes of Program Modeling and P Rros2 12.1 Case Sudy of Conmuication Betwarn Ochoa Reiss 567 123 nba Syste ia Autre 374 12.3 Cave Stay of am Embedded Stem oe an Adie Case Cantol (ACC) Sytem in Cor 377 12.4 Cae Sty ofa Embed Sytem ora Stat Cand S48 25. Cine Sly oa Mable Phone Sta or Key Iga vgramming with 13, imbedded Softare Development Process und Tuo 1.1 Insoducsion Enid Sotware Develapent Press and Tals 620, 132 Most and Target Maines 62! 15.3 Linking and Locating Solware 626 138 Going Embedded Soware ino the Target System 630 18S sues im Hrdvane-Software Design and Co-deign 34 1H. Testing, Simulation and Debugging Teetiques and Tools 1 Testing oo Hest Mashine 649 142 Simolsters 650 143 Laboratory Toole 655 Anpends I Roadmap for VariltCoe Sates Agpex2: Selec Bibigriphy Indes e 406 ” ts oss 602 63 - Walkthrough TEAL ge aap veoh (| Simple way of point-wise presentation of the details by | | | ‘Summary, Keywords and thet Gelintions, review questions - and practice exercises in each chapter ‘Waiktheough ‘Walkthrough l xi) x Explains modeling of programs and sokwareenginesing practices fr system design by Comprehensive explanation with coding exams for Case studies of systems fr automatic choclate vending mactine, ita camera, TOP! learn he dey used ATOSeS. mCOS, Vator, IP stack creation, abot orcosta, automatic use contol, smart caréand mobile phone ts enlace emai manteai { opendis2: select Bil Detailed selected biography of books, journal references and important web tnks at end ofthe book ofacitate bling a startup Ivar for references and further studies in Embedded Systems Wiatktraugh Introduction to Embedded Syste a £ A R NN I N G HRRRANRS BO Sia wee OF TEeNN@LOGY UmRARY EANGALONE - S00 60, ACN, Ho. Section 1 Deftions of system and embedded system Section 1.2 The processing unit of an embeded system consists of 1. A processor 2 Canmonly used microprocessors 3. Applicationspecific intrction set processors (ASTPst ‘nicraconrllers, DSPs ard others Single purpose processors Section 1.3 The hardieare it of an embeded stem consists of 1 An embedded ‘sem poser source with esate peace ddssipaion 2 Aclack oscillator circuited clocking unit hat eta processor 3. Timers and areal me clock (RTC) or various timing needs ofthe stem 4. Rese circuit nd watchdog timer 5. System and external memories 6, System input ouput (10) ports, sera, parallel and wireless communication, serial Univeral Asynchronous Receiverand Transmiter (UART) and other port protcols ad buses 7, Devices such as Digital to Analog Converter (DAC) using Pulse With Modulation PWM), Analog to Digital Converter (ADC) Ligit Emiting Diode (LED) and Liquid Crystal Display (LCD) units, keypad and keyboard, touch screen, pulse dialer, madem and transeiver 8 Muliplexers, deruliplerers, decoder for interfacing of he devices and buses L £ A R N I 22 ° a mes & 9 trig conor (aer Seaton Ls 1 Languages tha are sed develop embeded software fora stem 2. Program modes 4, Matting using on operating sytem (08), tom device driver, device sunagemen and real tne operating stem (RTOS) 4 Sofmre tos for em design Seton 15 vaples of epplicion: of embedded sytem Seton U6 Designing on embedded stem ona VLSI chip 1 Embed SC (Sytem on Chip) and eampls of ts eplicatons 2. Uses of Application Specie Ison Set Pres (ASIP) ad Inelecual Property TP) coe 4. Fld Pregraoable Gate Array (FEGA coe wth single or maple pocesar ants onan ASIC chip section 17 The comes tem consis of 1. Embedded microprocessors or GPPs i complex ses 2 Ebeling ASIP mcrconrlers, DSPs. med an ner processors 1. Bnei appcatiom specie sem processor (ASSP 4 Enbedng ralipteprocesors in ytens section 18 The devon process has 1 Changes In embeded stem design 2 Design mers opiniation 43. Code of harvard sofware componens Section 19 The sate design forma defined Seton 110 The design of embeded harvard sofare in an awomatc chocolate vending machine smartcard dsacanera able phone. mobile compe ar ar five as examples Section Lt Classification of embeded sens ino thre res Section 112 Sls needed to dsgn an embedded sem Invoducton o Embedded Systems f J 1.1 “EMBEDDED SYSTEMS 1.4.1 System ‘Asystem is « way of working organizing or doing one or many tasks acconling oa fixed plan, program. or exof rales A system salsoan arrangement in which lls units ssemble and work together according tothe plan or program ‘Consider a watch. Iti atime-splay system. Is pars ate its hardware, needles and batery with the beautiful dial, chasis and sap. These pars organize Zo show the real ime every second and cominvously tpdate the ime every second, Te system program updates the display using three needles afer each second, follows ast of rales. Some ofthese rule area follows: () All needles move only clockwise. i A thin and Tong needle rotates every second such that it earns to same positon ater a minut. (i) A Tong needle rotates very minute such that it returns to same position after an hour, (i) A short nee ote every hour sch that ftretums to same position after twelve ours. (¥) All thee needles etum tothe same inctnation ater twelve hours each day ‘Consider a washing machine, It isan automatic clothes-vashing sytem, The important hardware parts include ils status display pane, the switches and dials for user-defined programming, 2 motor to rotate or ‘pin, its power supply and contol unit sn inner water-level sensor a solenoid valve for ling water in and nother valve fr keting water Uain out, These parts organize to wash clothes automatically according 10 & program preset by a uset. The system-program is activated to wash the diy clothes placed ina tank, which fotales oF spins in preprogrammed steps and stages. follows a set of rules. Some of these rules are as follows: ( Follow the steps strictly in the following sequence. Step I: Wash ay spinning the motor according to programmed peiod. Step I: Rinse in Fesh water after draining out the dity wate, and rinse @ second time ifthe system snot programmed in water-saving mde, Sep II: After daining out the water completely spin the motor fs fora progranimed period for ding by eentuging out water from the clothes. Sep TV: ‘Show the wash-over status bya blinking display. Sound the alam for 2 miwe to signal thatthe wash cycle is compete. (i) At each step, display the process stage ofthe system. i) In ease of an interuption, execute only the remaining part of the program, starting fom the postion when the process was interupted, There fan Beno repetition from Step Lunlss the wer resets the system by inserting anoer se of clothes ad resets the progra 4.1.2 Embedded System Definition One of the definitions of embeidd system is a follows “An embedded system isa system that has embedded sofware and conputerhardware, which wakes it «system dedicaied for an applications) or specie part of an application or product ora part ofa larger Embedded systems have been dened in books published recently in several ways. Given below isa eres of definitions fom others in the eld ‘Wayne Wolf author of Computers as Components ~ Principles of Embedded Computing System Design: “what is an embedded computing sytem? Loosely defined, iis any device that includes a programmable ‘computer bus not itself intended to be a general-purpose computer” nd “a fax machine or aclock bil rom mieroprocessor is an embedded computing system" i ex Embedded Systems. EAS: " BM author of Bnbeed Mirocontles “Embedded Sytem se eectonc sens ta aa microprocessor or microcontoller, tut we do aot think of them as computersthe compote hidden or embedded in the system.” David E. Simon author of Ar Embedded Safoware Primer: ‘any computer system hidden in ny ofthese products InP tear a an eodction tothe Design of Smal cole Embedded Stems with examples Freeney CRHCOS8 miroconroles: (I “An embedded system ks sytem whose rp function is not compu “People use the term embeded sytem to mean system, hidden from view, forming an integral pat of microconiroller-base, software driven, rela {teractve, operating on diverse physical vai and cost-conscious market" the greater whole". (2) “An embedded system is a real time control system, autonomous, or human- or network ls and in diverse environments, and sold into a competitive ‘computerisation conpnents 1" Amisepeesor 2 Auge memay eth loin to ks (Prima mean mond eis Rado Acs Mey (RAM, Rely Nee (ROM) and fast accessible caches) ae mane aes (© Sesinary meno innermost nhs, tes an cade pes ope Imeony in CD-ROMs or memory sks (in mobile compute] ising ohh dee Pans con eed ne mayen 3. vodissch sachsen meen tc 4 lp ois chase nce dias eae 5: Outpt ans sich aan LCD ses, es ra eee 6, Networking unis uch ners et, fr end aces ed set bs ive, ex 1 Av oping system (0S) th hs pene use wer sa pss a tay non ‘Anemone syst is sym ht as te min components nbd tit "Kendriya Snr aconpute Fg hw hoist eat fan embed {aiem Asta niente KOM orathmeme, teal one hadi oed CD menor as nts 2. Renbet min epteaon ts er proceso eae 3. Hembeds a realtime operating sytem (RTOS) that sp vare. The application software may concurrently perform a series of ervises the application software running on to the procties of tasks in the system, It Perea saomectanism tole the processor una process as sched and contextswich berocee he cet ae ee, Ti cone of process, tread and ask explained ner in Sections 71 te 3g Ste les rng te exestion ofthe appleaonotvae TA aac oi to ‘not embed the RTOS.) a ° Irroducton to Embedded Systoms reaones | verte Omer Crt Pons [outputs intertocinge | | | 1 _} L_Baergecse : 3 i : i Fig. 1.1 The components of embedded system hardware and evens have different rates and time istinet rates. For example, audio, vdeo, data, network steam and ie constrains (2) Complex algorithms. (3) Complex graphic user interfaces (GUIs) and other user inter (4) Dedicated functions. Constraints An embed system design ping in vw the costs: (1 arise system reno, ie peso sp) dt sitive re en Conia ee of wat Tor ven ra Op wake ad lp "he system dein or an embed ye has cnsins with ear fo perfomance power ie and

Вам также может понравиться