Embedded Systems: Technical Publications
Embedded Systems: Technical Publications
Embedded Systems: Technical Publications
Embedded Systems
A Conceptual Approach
A. R Godse, A. 0. Mulani
TECHNICAL
PUBLICATIONS technical@vtubooks.com
An U p-Thrust lo r Knowledge www.technicalpublications.org
Embedded Systems
(i)
About the Author
A. P. Godse
• Completed M.S in Software Systems with distinction from Birla Institute of Technology.
• Completed B.E. in Industrial Electronics with distinction from University of Pune in 1990.
• Worked as a Professor at Vishwakarma Institute of Technology, Pune.
• Worked as a Technical Director at Noble Institute of Technology, Pune.
• Worked as selection Committee member for M. S. admission for West Virginia University,
Washington D.C.
• Developed Microprocessor Based Instruments in co-ordination with Anna Hazare for
Environmental Studies Laboratory, at Ralegan Siddhi.
• Developed Microprocessor Lab in-house for Vishwakarma Institute of Technology.
• Worked as Subject Expert for a State Level Technical Paper Presentation Competition, Pune.
• Awarded on 26th Ja n 2 0 0 1 by Pune Municipal Corporation for contributing in education field
and technical writing.
• Awarded as a “Parvati Bhushan Puraskar” for contributing in the education field.
• Since 1996, writing books on various engineering subjects. Over the years, many of books are
recommended as the reference books and text books in various national and international
engineering universities.
(ii)
E mbedded Systems
Atul P Godse
M. S. Software Systems (BITS Pilani)
B.E. Industrial Electronics
Formerly Lecturer in Department of Electronics Engg.
Vishwakarma Institute of Technology
Pune
Altaf O. Mulani
M.Tech. [Electronics - Digital System]
Lecturer in E & Tc Dept.
Vishwakarma Institute of Information Technology
Pune
TECHNICAL
PUBLICATIONS
An Up-Thrust for Knowledge
(iii)
Embedded Systems
All publishing rights (printed and ebook version) reserved with Technical Publications. No part of this book
should be reproduced in any form, Electronic, Mechanical, Photocopy or any information storage and
retrieval system without prior permission in writing, from Technical Publications, Pune.
Published b y :
® TM Amit Residency, Office No.1, 412, Shaniwar Peth, Pune - 411030, M.S. INDIA.
TECHNICAL P h .: +91 - 0 2 0 -2 4 4 9 5 4 9 6 /9 7 , T e le fa x : +91 -0 2 0 -2 4 4 9 5 4 9 7
P U B LIC A T IO N S Email : technical@vtubooks.com Website : www.technicalpublications.org
Printer :
Repro India Ltd.
5 0 /2 T T C , M ID C ,
M ahape, N avi M um bai
9 7 8 9 3 5 0 9 9 3 |- O
IS B N 9 7 8 9 3 5 0 9 9 3 1 7 0 (P rin te d B o o k )
(iv)
9789350993170 [1] 9789350995020 [1]
Preface
T h e im p o rta n c e o f E m b e d d e d S y s te m s is w e ll k n o w n in v a rio u s e n g in e e rin g fie ld s .
O v e rw h e lm in g re s p o n s e to o u r b o o k s o n v a rio u s s u b je c ts in s p ire d us to w rite th is b o o k .
T h e b o o k is s tru c tu re d to c o v e r th e key a s p e cts o f th e s u b je c t E m b e d d e d S ystem s.
T h e b o o k uses p la in , lu c id la n g u a g e to e x p la in fu n d a m e n ta ls o f th is s u b je c t. T he b o o k
p ro v id e s lo g ic a l m e th o d o f e x p la in in g v a rio u s c o m p lic a te d c o n c e p ts a n d ste p w is e m e th o d s
to e x p la in th e im p o rta n t to p ic s . Each c h a p te r is w e ll s u p p o rte d w ith nece ssa ry illu s tra tio n s ,
p ra c tic a l e x a m p le s a n d s o lv e d p ro b le m s . A ll th e c h a p te rs in th e b o o k a re a rra n g e d in a
p ro p e r s e q u e n c e th a t p e rm its e a c h to p ic to b u ild u p o n e a rlie r s tu d ie s. A ll c a re has be e n
ta k e n to m a k e s tu d e n ts c o m fo rta b le in u n d e rs ta n d in g th e b a s ic c o n c e p ts o f th e s u b je c t.
T h e b o o k n o t o n ly co v e rs th e e n tire s c o p e o f th e s u b je c t b u t e x p la in s th e p h ilo s o p h y o f
th e s u b je c t. This m a k e s th e u n d e rs ta n d in g o f this s u b je c t m o re c le a r a n d m a k e s it m o re
in te re s tin g . T h e b o o k w ill b e ve ry useful n o t o n ly to th e s tu d e n ts b u t a ls o to th e s u b je c t
te a c h e rs . T h e s tu d e n ts h a v e to o m it n o th in g a n d p o s s ib ly h a v e to c o v e r n o th in g m o re .
W e w ish to express o u r p ro fo u n d th a n k s to a ll th o s e w h o h e lp e d in m a k in g th is b o o k a
re a lity . M uch needed m o ra l s u p p o rt and e n c o u ra g e m e n t is p ro v id e d on n u m e ro u s
o c c a s io n s by o u r w h o le fa m ily . W e w ish to th a n k s th e Publisher a n d th e e n tire te a m o f
Technical Publications w h o h a v e ta k e n im m e n s e p a in to g e t th is b o o k in tim e w ith q u a lity
p rin tin g .
Authors
A. P. Godse
A. O. Mulani
Dedicated to my Mother, Father, Sister, Brother and last but not the least my
Wife and my Child's Alvia and Subhan.
- /dliafi /Hulani
(V)
Table of Contents (Detail)
Chapter -1 Embedded Computing (1 -1) to (1 - 30)
1.1 Introduction............................................................................................. 1 -1
1.2 Complex Systems and Microprocessors............................................... 1 - 1
1.2.1 Embedding Computers.......................................................................................................... 1 -8
1.2.1.1 Processor Embedded into a System................................................................................. 1 -9
1.2.2 Characteristics of Embedded System Applications............................................................ 1 -9
1.3 Embedded System Design Process..................................................... 1 - 1 0
1.4 Formalisms for System Design............................................................1 -1 2
1.4.1 Structural Description.......................................................................................................... 1- 13
1.4.1.1 Class Diagram................................................................................................................ 1-13
1.4.1.2 Object D iagram ............................................................................................................ 1-14
1.4.2 Behavioral Description........................................................................................................ 1- 16
1.4.2.1 Sequence Diagram........................................................................................................ 1-17
1.5 Design Exam ple.................................................................................... 1 - 1 9
1.5.1 Model Train Controller........................................................................................................ 1- 19
Review Questions.......................................................................................1 - 2 8
(vi)
2.3.6.1 Register A (Accum ulator).......................................................................................................... 2 - 9
2.3.6.2 Register B ............................................................................................................................... 2 - 1 0
2.3.6.3 Program Status Word (Flag R e g is te r ) .................................................................................2 - 1 0
2.3.0. 4 Stack and Stack P ointer..................................................................................................... 2 - 1 0
2.3.6.5 Data Pointer (D P T R )...........................................................................................................2- 11
2.3.0. 6 Program C o u n t e r .............................................................................................................. 2- 11
2.3.0. 7 Special Function Registers..................................................................................................2 - 1 2
3.1 Introduction..............................................................................................3 - 1
3.1.1 Steps Involved in Programming........................................................................................... 3 -1
3.1.2 Flow C h a rt.............................................................................................................................. 3 -2
3.1.3 Languages used for Programming..........................................................................................3 -3
3.1.3.1 Machine L a n g u a g e ................................................................................................................3 - 3
(vii)
3.1.3.2 Assembly Language.................................................................................................................. 3 - 3
3.1.3.3 High-Level L a n g u a g e .............................................................................................................. 3 - 4
3.1.3.4 Comparison between Programming L angua ges....................................................................3 - 4
5.1 Introduction............................................................................................. 5 - 1
5.2 External RAM and R O M ........................................................................ 5 - 1
5.2.1 Program M em ory................................................................................................................... 5 -1
5.2.2 Data M em ory......................................................................................................................... 5 -3
5.2.3 Important Points to Remember inAccessing External Memory............................................ 5 - 6
5.2.4 Memory Interfacing................................................................................................................. 5 -6
5.2.5 Interfacing Example............................................................................................................... 5 - 1 0
5.3 Interfacing Keyboard.............................................................................. 5 - 1 2
5.3.1 Key Debounce using Hardware............................................................................................5 - 1 3
5.3.2 Key Debouncing using S oftw are..........................................................................................5 - 1 4
5.3.3 Simple Keyboard Interface.....................................................................................................5 - 1 4
5.3.4 Matrix Keyboard Interface.....................................................................................................5 - 1 6
5.4 Interfacing Display................................................................................5 - 20
5.4.1 LED Displays..........................................................................................................................5 - 2 0
5.4.2 Interfacing LED D isplays.......................................................................................................5 - 2 2
5.5 Interfacing LCD Display....................................................................... 5 - 26
5.6 Interfacing DAC to 8051....................................................................... 5 - 33
5.6.1 IC DAC 1408 ....................................................................................................................... 5 - 3 3
5.6.1.1 Important Electrical Characteristics for IC 1408 ....................................................... 5-37
5.6.2 Interfacing DAC 1408 / DAC 0808 with 8051 .................................................................... 5 - 37
5.7 Interfacing ADC to 8051....................................................................... 5 - 41
5.7.1 ADC 0804 Fam ily................................................................................................................... 5- 41
5.7.2 ADC 0808/0809 F a m ily.........................................................................................................5 - 4 3
5.7.3 Interfacing of ADC 0803/0804/0805 with 8051.................................................................. 5 - 4 8
5.7.4 Sensor Interfacing - Practical Application............................................................................. 5 - 4 9
5.7.5 Interfacing of ADC 0844/0848 ............................................................................................ 5 - 5 0
5.7.6 Serial ADC Chip MAX1112/ MAX11 1 3 ............................................................................... 5 - 5 4
M
5.8 Stepper Motor Interface....................................................................... 5 - 59
5.9 DC Motor Interfacing............................................................................ 5 - 63
5.9.1 Pulse Width Modulation (PW M )............................................................................................5 - 6 4
5.9.2 DC Motor Control with Optoisolator...................................................................................5 - 6 5
5.10 Interfacing Examples......................................................................... 5 - 66
5.11 Multiple Interrupts................................................................................ 5 - 7 2
5.12 I/O Expansion using 8255.................................................................. 5 - 73
5.12.1 8255 Programmable Peripheral Interface (PPI)................................................................ 5 - 7 3
5.12.1.1 Features of 8 2 5 5 A .............................................................................................................. 5 - 7 5
5.12.1.2 Pin D escription.......................................................................................................................5 - 7 6
5.12.1.3 Block D ia g ra m .......................................................................................................................5 - 7 7
5.12.1.4 Operation M o d e s .................................................................................................................. 5 - 7 9
5.12.1.5 Control Word F o rm a ts ..........................................................................................................5 - 8 0
5.12.2 Connecting the 8031/51 to 8255 ..................................................................................... 5 - 8 3
5.12.3 8031 System with 8255 .................................................................................................... 5 - 8 8
5.12.4 Typical MCS-51 Based System ..........................................................................................5 - 9 0
5.12.5 8255 Interfacing................................................................................................................... 5- 91
5.12.5.1 Stepper Motor Interfacing using 8255 ............................................................................ 5- 91
5.12.5.2 LCD Interfacing using 8255 ............................................................................................. 5-92
5.12.5.3 ADC Interfacing using 8255 ............................................................................................. 5-94
5.12.6 Interfacing Exam ples...........................................................................................................5 - 9 6
Review Questions........................................................................................ 5 - 9 9
(xi)
6.5 Priority Inversion.................................................................................... 6 - 1 3
6.6 Message Queues................................................................................... 6 - 1 4
6.7 Mailboxes................................................................................................6 - 1 5
6.8 Pipes....................................................................................................... 6 - 1 5
6.9 Timer Functions..................................................................................... 6 - 1 6
6.10 Events................................................................................................... 6 - 1 6
6.11 Memory Management..........................................................................6 - 1 6
6.12 Interrupt Routines in an RTOS Environment..................................... 6 - 1 7
6.13 Comparison of the Methods for Intertask Communication................ 6 - 1 8
6.14 Comparison of the Three Methods of Protecting Shared Data....... 6 -1 8
Review Questions........................................................................................ 6 - 1 9
7.1 Principles..................................................................................................7 - 1
7.2 Encapsulating Semaphores and Queues ............................................. 7 - 2
7.3 Hard Real Time Considerations.............................................................. 7 - 3
7.4 Saving Memory Space.............................................................................7 - 4
7.5 Saving P o w e r.......................................................................................... 7 - 4
7.6 Micro C/OS-II............................................................................................7 - 5
7.7 Embedded Software Development Tools ............................................. 7 - 5
7.7.1 Host and Target Machines .................................................................................................. 7 -5
7.8 Getting Embedded Software into the Target System........................... 7 - 8
7.8.1 PROM Programmers............................................................................................................. 7 -9
7.8.2 ROM Em ulators..................................................................................................................... 7 -9
7.8.3 In-circuit Emulators................................................................................................................. 7 -9
7.8.4 Flash........................................................................................................................................ 7 -9
7.8.5 M onitors.................................................................................................................................. 7 -9
7.9 Debugging Techniques........................................................................ 7 -1 0
7.9.1 Testing on Host M achine.......................................................................................................7 - 1 0
7.9.2 Using Laboratory T o o ls .........................................................................................................7- 11
Review Questions...................................................................................... 7 - 1 2
(xii)
Chapter-8 Introduction to Advanced Architectures (8 -1 ) to (8-2 8)
8.1 Introduction...............................................................................................8 -1
8.2 ARM Processor (Advanced RISC Machine Processor)....................... 8 - 2
8.2.1 Processor and Memory Organization..................................................................................... 8 - 2
8.2.2 Programming Model................................................................................................................. 8 - 3
8.2.3 ARM Instruction S e t................................................................................................................. 8 - 4
8.2.4 Computing an Absolute Address using P C ...........................................................................8 - 8
8.3 SHARC Processor................................................................................. 8 - 1 0
8.3.1 Memory Organization.............................................................................................................8 - 1 0
8.3.2 Data Operations..................................................................................................................... 8- 11
8.3.3 Instruction Level Parallelism (IP L )........................................................................................8 - 1 6
8.4 Networked Embedded Systems............................................................ 8 - 1 6
8.4.1 Bus Protocols..........................................................................................................................8 - 1 7
8.4.2 l2C Bus (Inter Integrated Circuit Bus)................................................................................... 8 - 1 7
8.4.3 CAN Bus (Controller Area Network B u s).............................................................................8 - 1 8
8.5 Internet Enabled Systems.................................................................... 8 - 20
Review Questions........................................................................................ 8 - 2 7
(xiii)
(xiv)
Embedded Systems (A Conceptual Approach)
20%
OFF