Embedded Systems 9788122434989, 8122434983

Cover ; Preface ; Contents ; Chapter 1 Embedded Systems-An Introduction ; 1.1 Basic Idea on System ; 1.2 Embedded System

435 61 8MB

English Pages [255] Year 2011

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Cover......Page 1
Preface......Page 8
Contents......Page 10
1.2 Embedded Systems - Definitions......Page 16
1.3 Characteristics of Embedded Systems - an Overview with Examples......Page 17
1.4 Challenges in Designing an Embedded System......Page 21
1.5 Categorization of Embedded Systems......Page 22
1.6 Examples of Embedded Systems......Page 23
1.7 Quiz......Page 24
2.1 Understanding of Mictoprocessor and Microcontroller......Page 26
2.2 Functional Building Blocks of Embedded Systems......Page 27
2.3 Processor and Controller......Page 28
2.4 Memory, Ports and Communication Devices......Page 29
2.4.1 Memory......Page 30
2.4.3 Communication Devices......Page 31
2.5 Cisc Vs. Risc Processors......Page 32
2.6 General Purpose Processor and Dsp Processor......Page 33
2.7 Direct Memory Access......Page 34
2.8 Cache Memory and its Types......Page 37
2.9 Co-Design of Hardware and software......Page 38
2.10 System on Chip......Page 39
2.11 Tools for Embedded Systems......Page 40
2.12 Quiz......Page 44
3.1 Software Life Cycle......Page 46
3.2 Embedded Life Cycle......Page 48
3.3 Modeling of Embedded Systems......Page 53
3.4.1 Simulation......Page 65
3.4.2 Emulation......Page 66
3.5 Quiz......Page 68
4.1 Introduction......Page 69
4.2.1 The Hardware Layer......Page 70
4.2.2 The System Software Layer (or simply, the OS layer)......Page 72
4.2.3 The Middleware......Page 74
4.2.4 The Application Layer......Page 75
4.3 Quiz......Page 76
5.1 What is an Operating System?......Page 77
5.2 How is Resource Management Carried out?......Page 78
5.3 What is Kernel? ......Page 79
5.3.1 Kernel Components......Page 81
5.5 What is Real Time?......Page 84
5.6 Quiz......Page 87
Chapter 6 Real TimeOperating Systems—A Detailed Overview......Page 88
6.1.1 Comparison of UNIX and LINUX......Page 89
6.1.2 File System Architecture Details......Page 90
6.1.3 Types of File Systems in UNIX/LINUX......Page 91
6.1.4 Basic UNIX Commands......Page 92
6.1.5 /proc and File Descriptor Table......Page 93
6.2.1 Task......Page 96
6.2.2 Task States......Page 97
6.2.3 Task Transitions......Page 98
6.2.4 Task Scheduling......Page 99
6.3.1 Pipe......Page 113
6.3.2 Named Pipe......Page 117
6.3.3 Message Queue......Page 121
6.3.4 Shared Memory......Page 127
6.3.5 Task and Resource Synchronization......Page 132
6.4 Memory Management......Page 138
6.5 Cache Memory......Page 141
6.6 Dynamic Memory Allocation......Page 143
6.7 Fragmentation......Page 145
6.8 Virtual Memory......Page 146
6.9 Context Switching......Page 147
6.10 Quiz......Page 149
7.1 Serial Communication Basics......Page 150
7.1.1 RS-232 Model......Page 152
7.1.2 I2C (I Square C) Model......Page 154
7.2 Can and Can Open......Page 155
7.3.1 SPI......Page 158
7.3.2 SCI......Page 160
7.4 USB......Page 161
7.5 IEee1394-Apple Fire Wire......Page 163
7.6 Hdlc- an Insight......Page 165
7.7 Parallel Coommunication Basics......Page 166
7.7.1 PCI Interface......Page 167
7.8 Device Drivers-in Introduction......Page 169
7.8.2 Parallel Port Device Driver......Page 170
7.9 Quiz......Page 172
Chapter 8 An Overview andArchitectural Analysis of8051 Microcontroller......Page 173
8.1 Introduction......Page 174
8.2 Microcontroller Resources......Page 180
8.3 Internal and External Memory......Page 190
8.4 Memory Organization......Page 194
8.5 Timer or Counter......Page 195
8.6 Input and Output Ports......Page 196
8.7 Interrupts - an Insight......Page 198
8.8 Assembly Languge Programming......Page 201
8.9 Quiz......Page 209
9.1 Basic Introduction to Processors......Page 211
9.2.1 Different Versions of ARM Processor......Page 212
9.2.2 ARM Internals – Core Block Diagram......Page 213
9.2.5 ARM Programming Model and Data Types......Page 214
9.2.6 C Assignments in ARM – A Few Examples......Page 215
9.3.1 SHARC Working Principle......Page 216
9.3.2 SHARC Addressing Modes......Page 217
9.4 Arm Vs. Sharc......Page 218
9.5.1 Core Features......Page 219
9.5.2 Memory and DMA......Page 220
9.5.4 Peripherals......Page 221
9.6 Ti-Dsp Processors......Page 222
9.7 Assemely Languge Programming on Hardware Processors......Page 223
9.8 Quiz......Page 226
10.1 Coding Standards-the Definition......Page 227
10.3 The Limitation......Page 228
10.4.1 Modularization......Page 229
10.4.2 Data Typing, Declarations, Variables and Other Objects......Page 230
10.4.3 Names......Page 231
10.4.4 Organizing Control Structures......Page 232
10.4.5 Program Layout......Page 235
10.4.6 Comments and (program) Documentation......Page 239
10.5 Project Dependent Standards......Page 241
10.6 Summary......Page 242
11.1 Embedded System - Design......Page 243
11.2 Designers Perspective......Page 244
11.4 Implementation of the Proposed System......Page 249
11.5 Quiz......Page 254
Recommend Papers

Embedded Systems
 9788122434989, 8122434983

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Embedded Systems

This page intentionally left blank

Embedded Systems D.P. Kothari

Shriram K Vasudevan

FNAE, FNASc Fellow-IEEE Director General, VITS, Indore Former Vice-Chancellor VIT University, Vellore Former Director i/c, IIT, Delhi Formerly Principal, VRCE, Nagpur

B.E., M.Tech., Senior Engineer in MNC Chennai

Sundaram R M D

Murali N

B.E.(Electronics & Communication Engineering), M.Tech Developer in MNC Bengaluru

B.E.(Electrical & Electronics), M.Tech, Lecturer in Nizwa College of Technology, Oman

Copyright © 2012, New Age International (P) Ltd., Publishers Published by New Age International (P) Ltd., Publishers All rights reserved. No part of this ebook may be reproduced in any form, by photostat, microfilm, xerography, or any other means, or incorporated into any information retrieval system, electronic or mechanical, without the written permission of the publisher. All inquiries should be emailed to [email protected] ISBN (13) : 978-81-224-3498-9

PUBLISHING FOR ONE WORLD

NEW AGE INTERNATIONAL (P) LIMITED, PUBLISHERS 4835/24, Ansari Road, Daryaganj, New Delhi - 110002 Visit us at www.newagepublishers.com

Dedication Kothari, D.P.—To son-in-laws Pankaj and Rahul Shriram K Vasudevan—To Parents and Sister Sundaram R M D—To Mom and Dad Murali N.—To Friends and Parents

This page intentionally left blank

Preface Embedded Systems, present almost everywhere, have occupied an inevitable place in the market. We, the consumers, live with Embedded Systems all the way, be watches, mobile phones, refrigerators, cars, music systems and what not… Even the medical field is fully supported with the modern equipments which too, are embedded systems. Embedded Systems occupy a vital place in military as well, where weapons mostly come under this category. Automobile industry will become handicapped without Embedded Systems. In this book, every topic has been supported with practical examples. In addition, the programming concepts have been fully supported with simple and elegant C codes which have been executed in Linux OS as well. After every chapter, the reader is presented with a set of interesting quiz questions, which will make the reader think for sure. In short, it will be good and friendly learning experience for the reader. We have covered the basics of Embedded Systems in Chapter-1 followed by building blocks (components) of the system. Then the book moves towards the design methodologies and modeling of Embedded Systems in Chapter-3. Layered approach is being followed in building an Embedded System. This approach has been discussed in Chapter-4. Chapters-5 and 6 cover the basics of operating system and programming with C in Linux. Chapter-7 is on networks for Embedded Systems. Then microcontrollers are discussed in the next two chapters which include 8051 to latest ARM controllers. A practical example is also indepth discussed in chapter-11 after discussing the coding guidelines in chapter-10.

viii

Preface

We wish to thank all the good hearts who have helped us in this project. In particular, we wish to thank Subashri V, Sriram Karthik, Sivaraman R, and Sunandhini M for their immense help and support in bringing the book to a good shape. We welcome any constructive criticism of the book and will be grateful for an appraisal by the readers. The suggestion can be sent to [email protected] D.P. Kothari Shriram K Vasudevan Sundaram R M D Murali N.

Contents Preface 1. Embedded Systems—An Introduction

vii 1—10

1.1 Basic Idea on System

1

1.2 Embedded Systems – Definitions

1

1.3 Characteristics of Embedded Systems – An Overview with Examples

2

1.4 Challenges in Designing an Embedded System

6

1.5 Categorization of Embedded Systems

7

1.6 Examples of Embedded Systems

8

1.7 Quiz

9

2. Components of Embedded Systems

11—30

2.1 Understanding of Microprocessor and Microcontroller

11

2.2 Functional Building Blocks of Embedded Systems

12

2.3 Processor and Controller

13

2.4 Memory, Ports and Communication Devices

14

2.4.1 Memory

15

2.4.2 Ports

16

2.4.3 Communication Devices

16

2.5 CISC vs. RISC Processors

17

2.6 General Purpose Processor and DSP Processor

18

2.7 Direct Memory Access

19

2.8 Cache Memory and its Types

22

2.9 Co-design of Hardware and Software

23

Contents

x

2.10 System on Chip

24

2.11 Tools for Embedded Systems

25

2.12 Quiz

29

3. Design Methodologies, Life Cycle and Modeling of Embedded Systems

31—53

3.1 Software Life Cycle

31

3.2 Embedded Life Cycle

33

3.3 Modeling of Embedded Systems

38

3.4 Simulation and Emulation

50

3.4.1 Simulation

50

3.4.2 Emulation

51

3.5 Quiz

53

4. Layers of an Embedded System

54—61

4.1 Introduction

54

4.2 Need for Layering

55

4.2.1 The Hardware Layer

55

4.2.2 The System Software Layer (or Simply, the OS layer)

57

4.2.3 The Middleware

59

4.2.4 The Application Layer

60

4.3 Quiz 5. Real Time Operating Systems (RTOS) —An Introduction

61 62—72

5.1 What is an Operating System?

62

5.2 How is Resource Management Carried Out?

63

5.3 What is Kernel?

64

5.3.1 Kernel Components

66

5.4 Why RTOS is Needed?

69

5.5 What is Real Time?

69

5.6 Quiz

72

6. Real Time Operating Systems—A Detailed Overview 6.1 LINUX – An Introduction

73—134 74

Contents

xi

6.1.1 Comparison of UNIX and LINUX

74

6.1.2 File System Architecture Details

75

6.1.3 Types of File Systems in UNIX/LINUX

76

6.1.4 Basic UNIX Commands

77

6.1.5 /proc and File Descriptor Table

78

6.2 RTOS Concepts

81

6.2.1 Task

81

6.2.2 Task States

82

6.2.3 Task Transitions

83

6.2.4 Task Scheduling

84

6.3 Inter Process Communication (IPC) Methodologies 6.3.1 Pipe

98 98

6.3.2 Named Pipe

102

6.3.3 Message Queue

106

6.3.4 Shared Memory

112

6.3.5 Task and Resource Synchronization

117

6.4 Memory Management

123

6.5 Cache Memory

126

6.6 Dynamic Memory Allocation

128

6.7 Fragmentation

130

6.8 Virtual Memory

131

6.9 Context Switching

132

6.10 Quiz

134

7. Networks for Embedded Systems 7.1 Serial Communication Basics 7.1.1 RS-232 Model 2

7.1.2 I C (I Square C)Model

135—157 135 137 139

7.2 CAN and CAN Open

140

7.3 SPI and SCI

143

7.3.1 SPI

143

7.3.2 SCI

145

7.4 USB

146

Contents

xii

7.5 IEEE 1394 – Apple Fire Wire

148

7.6 HDLC – An Insight

150

7.7 Parallel Communication Basics

151

7.7.1 PCI Interface

152

7.7.2 PCI-X Interface

154

7.8 Device Drivers – An Introduction

154

7.8.1 Serial Port Device Driver

155

7.8.2 Parallel Port Device Driver

155

7.9 Quiz 8. An Overview and Architectural Analysis of 8051 Microcontroller

157 158—195

8.1 Introduction

159

8.2 Microcontroller Resources

165

8.3 Internal and External Memory

175

8.4 Memory Organization

179

8.5 Timer or Counter

180

8.6 Input and Output Ports

181

8.7 Interrupts – An Insight

183

8.8 Assembly Language Programming

186

8.9 Quiz

194

9. Advanced Architectures

196—211

9.1 Basic Introduction to Processors

196

9.2 ARM Architecture

197

9.2.1 Different Versions of ARM Processor

197

9.2.2 ARM Internals – Core Block Diagram

198

9.2.3 ARM – Register Set

199

9.2.4 ARM – Instruction Set

199

9.2.5 ARM Programming Model and Data Types

199

9.2.6 C Assignments in ARM – A Few Examples

200

9.3 SHARC Architecture

201

9.3.1 SHARC Working Principle

201

9.3.2 SHARC Addressing Modes

202

9.3.3 SHARC – C Assignments with Examples

203

Contents

xiii

9.4

ARM vs. SHARC

203

9.5

Blackfin Processors

204

9.5.1

Core Features

204

9.5.2

Memory and DMA

205

9.5.3

Microcontroller Features

206

9.5.4

Peripherals

206

9.6

TI-DSP Processors

207

9.7

Assembly Language Programming on Hardware Processors

208

9.8

Quiz

211

10. Coding Guidelines

212—227

10.1

Coding Standards—The Definition

212

10.2

The Purpose

213

10.3

The Limitations

213

10.4

Common Programming Standards

214

10.4.1 Modularization

214

10.4.2 Data Typing, Declarations, Variables and Other Objects

215

10.4.3 Names

216

10.4.4 Organizing Control Structures

217

10.4.5 Program Layout

220

10.4.6 Comments and (Program) Documentation

224

10.5

Project Dependent Standards

226

10.6

Summary

227

11. Embedded Systems—Application, Design and Coding Methodology

228—240

11.1

Embedded System–Design

228

11.2

Designers Perspective

229

11.3

Requirements Specifications

234

11.4

Implementation of the Proposed System

234

11.5

Quiz

239

This page intentionally left blank



Embedded Systems —An Introduction

Learning Outcomes o

Basic Idea on System

o

Definition of Embedded Systems

o

Characteristics of Embedded Systems

o

Challenges in Designing an Embedded System

o

Categorization of Embedded Systems

o

“Examples of Embedded Systems”

o

Recap

o

Quiz

Embedded Systems are available everywhere in this modern world. This chapter will touch on all basic aspects of understanding an Embedded System. 1.1 BASIC IDEA ON SYSTEM What is a System? A system can be defined as simple as “It can accept some input, analyze and then it should give us the output that the system is meant for or it should drive the next piece of machine connected to it.” 1.2 EMBEDDED SYSTEMS – DEFINITIONS Definition of Embedded Systems can now be seen. Many people have given many definitions all over the world. If internet is surfed for definition of an embedded system one will get enormous amount of results getting displayed. Few of them are picked here to add clarity and finally embedded system can be defined in a smooth way. According to Wayne Wolf, “An Embedded System is a computing system other than desktop computers.” This looks pretty simple and other definitions are as follows:

Embedded Systems

2

• An embedded system is the one that has computer hardware with software embedded in it as one of its most important components. • It is a device that includes a programmable computer but is not itself intended to be a general purpose computer. Embedded System can be well defined by taking couple of classical examples. First, an air conditioner is taken for understanding. What does an air conditioner do? The temperature is set as per requirement, say 20 °C. There may be variations in external temperature and that will also reflect in the room air conditioner is fitted. But however the external temperature varies, the AC machine facilitates user with cool atmosphere (i.e., 20 °C) inside the room as per requirement. What is the action taken? Consider a second example of the pace maker. Its work is to trigger the heart beat if at all heart is getting into trouble. How is this done? Answers for both the questions are the same. When looking into the definition of an Embedded System, one can get answer for above quoted cases. •

An electronic controller built into the application, continuously monitors the process variables and ensures that the Process Variable (PV) does not change; in the event of a change the controller generates a counteracting signal applied to the application so that the deviated PV is brought to its normal operating value. This could define embedded systems clearly!

So here it is made very clear. In air conditioner, temperature is the process variable. A controller inside will keep on monitoring the process variable. If at all the room temperature changes due to variation in external temperature, controller will take a counter acting signal and PV (temperature) will be brought to required range. Second case, controller inside a pace maker will keep monitoring the heart beat count. If it is getting low, immediately a counter acting action will be taken and it will boost up the heart. Food for brain! Is laptop an embedded system?—This question will be answered shortly! 1.3 CHARACTERISTICS OF EMBEDDED SYSTEMS – AN OVERVIEW WITH EXAMPLES When provided with a system, it should be identified if it is an Embedded System. Certain common characteristics are there for all Embedded Systems. Having able to understand the characteristics, embedded systems can be spotted easily. • Single Functioned

Embedded Systems—An Introduction

3

• Tightly Constraint • Real Time and Reactive • Complex Algorithms • User Interface • Multi Rate Each of the above characteristics are discussed below in detail. 1. Single Functioned An Embedded System can execute a specific function repeatedly i.e., dedicated function. As an example, Air conditioner will be cooling the room. Cooling is its dedicated functionality and it cannot be used for any other purposes. AC can’t be used for making calls. Likewise mobile phone is an Embedded System that can be used to make and receive calls and it can’t be used for controlling room temperature. Consider the list of embedded systems that are being used every day. 1. Pager. 2. Microwave oven. 3. Mobile phone. 4. ATMs. 5. Car braking systems. 6. Automobile cruise controllers. 7. Pace makers. 8. Modem. 9. Network cards and many more.

Fig. 1.1: Few applications of embedded systems (all single functioned)

4

Embedded Systems

From the examples quoted it is understood about single functioned behaviour of Embedded Systems. Is Laptop an Embedded System -> No, since it can be used for different purposes. It can play media players and at the same time, laptop can be used as a gaming machine. And the next day it can be used for typing data. So it is multifunctional and it can’t be an Embedded System. 2. Tightly Constraint Whatever system is being designed, they have constraints. Embedded Systems are also tightly constraint in many aspects. Few aspects are being analyzed here. 1. Manufacturing Cost 2. Performance 3. Size 4. Power The above four parameters decide the success of Embedded System. Consider buying a mobile phone as an example. If the mobile phone costs in lakhs, will it be bought? (Instead Landline phone would be preferred). Next scenario, the mobile phone that is bought, if it takes 1/2 an hour for making a call and if it also hangs frequently, will it be opted? (No Way!). Third point if the phone is weighing 3 kgs, will it be preferred? Finally coming to power criteria. All embedded systems are almost battery operated. And it is mobile as well! So it should be capable of retaining the charge for some reasonable amount of time. Else the battery will drain faster and one has to keep charger handy all the time. So it is very important to have this constraint in mind when designing an embedded system. 3. Real Time and Reactive What is real time? —A nice question to start with! A definition can be given through an example here. Take an instance of travel in BMW car. (Great feel it would be). (The braking system is an embedded system). And unfortunately a lorry is coming opposite to the car... The driver is applying brake there!. What would be the action required? It should immediately stop the car right. This is a real time and reactive behaviour. The brake may be applied at any point in time. And the vehicle should be stopped immediately at the instance of applying brake. It is never known when brake has to be applied, so the system should be ready to accept the input at any time and should be ready to process it.

Embedded Systems—An Introduction

5

So keeping above example in mind and defining Real Time, it is logical correctness of the operation in deterministic deadline. (The vehicle should be stopped immediately, which means as logical correctness of the operation in deterministic deadline) Few examples can be spotted for Real time and Reactive behaviour of an Embedded System: (a) Pace Maker’s action. (b) Flights Landing Gear Control. (c) ECG Machines output. And so on … Many examples could be cited here! 4. Complex Algorithms The processor inside the embedded system should perform operations that are complex in nature. An example is digital camera. It is used to take color photographs, motion pictures, black and white pictures, etc. It needs to pull in lots of complex algorithms for performing all the above mentioned operations. So as a point to conclude, every embedded system will have lots of complex algorithms running inside it. 5. User Interface Here too with an example the concept can be explained. NOKIA mobile phones are very big hit in market right, Why? What is the reason? Is that because other mobile did not perform well? No, is the answer. Nokia had excellent and simple user interface. Calls can be made and received very easily. Typing SMS is also easier… So it has been read by the people very well. So designing system with easier and comfortable interface is most important. Also it should have options required for the operation of the device. Example is ATM machine; it has got comfortable interfaces and options. Keep it in mind and design the system. 6. Multi Rate Embedded Systems need to control and drive certain operations at one rate and certain other operations at different rate. Example can be Digital Camera. It is used to take pictures which are still. Also it is capable of shooting video. So it has to be capable of driving the first operation from a speed different than the second one. A Small Recap: Please do not forget the definition of Real Time; down the line it will be needed.

Embedded Systems

6

1.4 CHALLENGES IN DESIGNING AN EMBEDDED SYSTEM First and foremost problem in designing an Embedded System is “Very Less Availability of Tools and Debuggers”. Other than the point quoted, there are several other challenges. Meeting Deadlines

Embedded System Design Challenges

Hardware Hardware Selection Selection

Upgradability Upgradability

Will Willititwork? work?

Fig. 1.2: Challenges in embedded system design

Figure 1.2 diagrammatically represents the challenges. Reader will be exposed to all these challenges with some relevant examples. 1. Meeting Deadlines How can the deadline be met that is meant for the product? Meeting deadline accurately will need high speed hardware. Increasing hardware components with quality would increase the cost of the product. This is the first challenge in front of designers. 2. Hardware Selection Embedded Systems never had a luxury of having much hardware. Taking memory into consideration first, Embedded Systems will have very little inbuilt memory. Adding more memory of smaller size will increase cost factor. So keep memory only as much as needed. It can have an expansion slot for the system, if user is willing to expand memory, who bothers, let user expand. Coming to processor selection, if a very high speed processor is selected, it would end up in draining the battery at the earliest. But it can’t be compromised with speed also. So select a processor that perfectly fits in with requirement. Too high speed processor would cost more and can drain battery also. 3. Is it upgradable and maintainable? Assume that a mobile phone has been designed and it is released in the market. But after reaching people the product was found with problems in one or two

Embedded Systems—An Introduction

7

aspects. The developer would know that problem and it can be fixed. But how will it reach the phone that had already reached public? So it must be supporting with upgradation of versions of software for it. Keep this in mind that the product should be upgradable with the same hardware! Secondly, when writing software for embedded systems, it should be kept in mind on maintainability. The code should not be just written in such a way that only developer who developed it can understand. It should be understandable for other engineers also. Other engineers should also be able to understand and fix bugs in the code if any, if need be. 4. Will it work? Nice Question. Isn’t it? Yeah. Please ensure if the system that has been designed is really working fine. How can it be ensured? Through rigorous testing it is possible; it needs to be proceeded with testing in many ways. First can be unit testing, next stage is Sanity Testing and the third stage can be Regression testing. Also even if the product has entered, it has to be constantly monitored. If any customer complaint rises, that bug has to be looked into and has also to be fixed. And more importantly, the bug that is fixed should not introduce any new bugs. Let’s now get to know about the categorization of the embedded systems! 1.5 CATEGORIZATION OF EMBEDDED SYSTEMS Embedded Systems can be categorized based on the complexity in building, cost factors, purpose of the system, tools and other related environment availability, etc. Keeping these points, table 1.1 has been framed and it has dealt with categories. Broadly one can classify embedded system into any of these, 1. Small Scale Embedded Systems. 2. Medium Scale Embedded Systems, and 3. Sophisticated Embedded Systems. Table 1.1: Categorization of Embedded Systems Small Scale Embedded System Processor

Here it can be 8 bit or 16 bit processor. (it can’t do computationally intensive process)

Medium Scale Embedded System

Sophisticated Embedded System

It can be a 16 bit or 32 bit processor here. (think of little complex and intensive process with this processor)

PLA, PAL, FPGA and ASIC will fall in this category. (These are high end design elements that can be used to do wonders)

Contd...

Embedded Systems

8 Hardware Complexity

Very little complexity will be visualized here.

We will have to face more complexity in terms of peripheral additions, interfaces etc.,

Highly Complex. (designers need enormous expertise to do proceed with this)

Software Complexity

No complexity will be there in this coding. Because the device is not meant for performing complex functionalities. Battery operated

There will be complexity added up. This will have few functions and code might be lengthy.

Yeah. Most Complex. Designer needs to be a master to work on the code.

Battery operated

Can be Battery or Live Source based on the application.

Can be programmed in simple environment. So no much research on tools is required here. Calculator can be the simplest example. Stepper motor controller can be added to the list.

Here we will have to use Debugger, Compiler, IDE etc., as the task goes slightly cumbersome.

Designer needs sophisticated environment here.

Washing Machine, Microwave Oven, and Vending machine.

Flight Landing Gear Systems, Car Braking Systems, Military Applications, Robots.

Power

Tools Availabiltiy

Examples

 1.6 EXAMPLES OF EMBEDDED SYSTEMS Coming to examples, everything around us can be taken! Yeah, each and everything these days are embedded systems. Let’s take this way. From the time of getting up in the morning, 1. Digital Water Heater! (After bath need to breakfast!). Here temperature is the process variable and it is the input to be set by user. Controller will take care on the controlling action and will take care of the heating process. 2. Microwave Oven (coffee after breakfast). Here again temperature will be the process variable. Same controlling action will be taken. 3. Braking System, Music Player, Tire Pressure Monitoring System, Airbags, Power Windows and GPS (Many more embedded systems are there inside … only 1% is quoted, workplace has been reached now. Car braking system can be an instance; it shows the real time and reactive behaviour. Brake would be applied at any point in time, but still it would stop the car.) 4.

All gym equipments from treadmill to cycling equipments are embedded systems.

Embedded Systems—An Introduction

9

5. Video games, all digital gaming machines, I pod, MP3/MP4 players, Xbox and what not! POINTS TO REMEMBER 1. An Embedded System is single functioned and AC can be remembered as a simple example. 2. Embedded Systems are Real time systems which is reactive in nature. 3. Many design challenges are associated with making an embedded system, including cost, power etc. 4. Embedded systems are classified into three major divisions—Small scale, medium scale and large scale embedded systems. Review Questions 1. What is an Embedded System? Give an example. 2. Embedded systems are quoted as single functioned systems. Justification is required in this case. 3. Define Real time. 4. Throw an example for real time and reactive embedded system. 5. What are the major categories of the Embedded Systems? Give an example for each division. 6. Is LCD projector an Embedded System? Please justify. 1.7 QUIZ 1. Pick odd one out! (Embedded is the clue) (a) Laptop (c) Mobile phone

(b) Projector (d) MP3 player

2. Some of the important characteristics expected in consumer electronics products are ________ (a) Recovering from failures (b) Low cost (c) Performance (d) Low unit cost, low power consumption and smaller product size 3. One of the most important characteristics of embedded systems for automotive industry (with respect to the inmates of the vehicle) is _________ (a) Recovering from failures

Embedded Systems

10

(b) Low cost (c) Safety (d) Low unit cost, low power consumption and smaller product size 4. __________ manages resources like CPU time and memory of an embedded system. (This is a general question, try to answer this. :) 5. Embedded system can do multiprocessing — True or False. 6. What is Real-time? Please give an example. 7. Give an example of multi rate characteristic of an Embedded System. 8. Embedded systems are almost battery operated – True or False. 9. Mobile phone is not an Embedded System – True or False. Answers for Quiz 1. Laptop 2. Low unit cost, low power consumption and smaller product size 3. Safety 4. Operating system 5. False 6. Braking, Pace maker’s behaviour can be a good example here. 7. A digital camera can work on a black and white image, color image, video and audio. Processing is different in all these which is referred as multi rate. 8. True 9. False (May be in future, Mobile phones would do multiple things and can break this question).

Components of Embedded Systems Learning Outcomes

2.1

o

Understanding of Microprocessor and Microcontroller

o

Functional Building Blocks of Embedded Systems

o

Processor and Controller

o

Memory, Ports and Communication Devices

o

CISC vs. RISC Processors

o

General Purpose Processor and DSP Processor

o

Direct Memory Access – Indepth Analysis

o

Cache Memory and its types

o

Co-design of Hardware and Software

o

System on Chip

o

Tools for Embedded Systems

o

Recap

o

Quiz

UNDERSTANDING OF MICROPROCESSOR AND MICROCONTROLLER

A microprocessor incorporates most or all of the functions of a computer’s central processing unit (CPU) on a single integrated circuit. A microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Microprocessors generally require external components to implement program memory, RAM memory and input/output. Intel’s 80186, 80188, and 80386 are examples of microprocessors. Microcontrollers incorporate program memory, RAM memory and input/output resources internal to the chip. Microchip’s ‘PIC’ series and Atmel’s ‘AVR’ series are examples of microcontrollers.

Embedded Systems

12

2.2 FUNCTIONAL BUILDING BLOCKS OF EMBEDDED SYSTEMS Embed means to fix (something) firmly and deeply or enclose something closely in a surrounding mass. Figure 2.1 shows a simple embedded system. The various blocks that build the embedded systems include ports, RAM, switch controllers, Reset software buttons, LAN, PCI card, JTAG connector, etc. Serial USB Power 2 port WAN Console (host) Printer port connector Switch Controller

JTAG

PCMCIA card

MCU Boot Flash Extension

4 port LAN

LEDs

SD RAM Flash

Reset S/W

Fig. 2.1: A simple embedded system

An embedded system has a different set of issues to deal with than does desktop software. This includes: (1) Handle situations that don’t arise with desktop software like doing several things at once, responding to external events (button presses, sensor readings, etc.). (2) Cope with all unusual conditions without human intervention including Meet strict processing deadlines and never fail. (3) Able to log issues when things go out of control which helps in debugging the issue later. Embedded Systems were initially hardwired systems and then were Microprocessor-based, then moved on to Microcontroller-based and Specialized (application) processors and finally we have reached System on a Chip (SOC).

Components of Embedded Systems

13

Address bus

Micro Processor

Memory System

Input/Output

Data bus Digital Outputs

Digital Inputs

Fig. 2.2: Basic building blocks of an embedded processor

Memory system forms a major block in embedded system. This includes RAM, ROM, cache memory and hard drive memory. There should be provision to provide input to the system by means of cable, SD cards etc. and proper output mechanism is also required to test the system functionality. The basic building blocks of embedded system are illustrated in Fig. 2.2. Required features for embedded system include ❏

Throughput



Response



Low power



Reliability



Safety



Maintainability



Cost, size and weight

2.3 PROCESSOR AND CONTROLLER Microprocessors generally require external components to implement program memory, RAM memory and input/output. Intel’s 80186, 80188, and 80386 are examples of microprocessors. Microcontrollers incorporate program memory; RAM memory and input/ output resources internal to the chip. Microchip’s PIC series and Atmel’s AVR series are examples of microcontrollers. Figure 2.3 depicts a PIC 18F8720 microcontroller in an 80-pin TQFP package. It is not unusual to see these terms used interchangeably. In simple terms, Microprocessor = CPU Microcontroller = CPU, peripherals and memory

Embedded Systems

14

Peripherals = ports, clock, timers, UART, ADC converters, LCD drivers, DAC and others. Memory = EEPROM, SRAM, Flash, etc About 55% of all CPUs sold in the world are 8-bit microcontrollers and microprocessors.

Fig. 2.3: A PIC 18F8720 microcontroller in an 80-pin TQFP package.

A typical home in a developed country is likely to have only four general-purpose microprocessors but around three dozen microcontrollers. A typical mid-range automobile has as many as 30 or more microcontrollers. They can also be found in many electrical devices such as washing machines, microwave ovens, and telephones. 2.4 MEMORY, PORTS AND COMMUNICATION DEVICES Computer data storage, often called storage or memory, refers to computer components and recording media that retain digital data used for computing for some interval of time. Computer data storage provides one of the core functions of the modern computer, that of information retention. It is one of the fundamental components of all modern computers, and coupled with a central processing unit (CPU, a processor), implements the basic computer model used since the 1940s. A register file is an array of processor registers in a central processing unit (CPU). Modern integrated circuit-based register files are usually implemented by way of fast static RAMs with multiple ports. Such RAMs are distinguished by having dedicated read and write ports, whereas ordinary multiported SRAMs will usually read and write through the same ports.We will discuss in detail about memory, ports and devices below.

Components of Embedded Systems

15

2.4.1 Memory Many types of memory devices are available for use in modern computer systems. The RAM family includes two important memory devices: static RAM (SRAM) and dynamic RAM (DRAM) as shown in Fig. 2.4. The primary difference between them is the lifetime of the data they store. SRAM retains its contents as long as electrical power is applied to the chip. If the power is turned off or lost temporarily, its contents will be lost forever. DRAM, on the other hand, has an extremely short data lifetime-typically about four milliseconds. This is true even when power is applied constantly. Memories in the ROM family are distinguished by the methods used to write new data to them, and the number of times they can be rewritten. This classification reflects the evolution of ROM devices from hardwired to programmable to erasable-and-programmable. A common feature of all these devices is their ability to retain data and programs forever, even during a power failure. In practice, almost all computers use a variety of memory types, organized in a storage hierarchy around the CPU, as a trade-off between performance and cost. Generally, the lower a storage is in the hierarchy, the lesser its bandwidth and the greater its access latency is from the CPU. This traditional division of storage to primary, secondary, tertiary and off-line storage is also guided by cost per bit.

Fig. 2.4: Writable volatile random access memory

As memory technology has matured in recent years, the line between RAM and ROM has blurred. Now, several types of memory combine features of both. These devices do not belong to either group and can be collectively referred to as hybrid memory devices. Hybrid memories can be read and written as desired, like RAM, but maintain their contents without electrical power, just like ROM. Two of the hybrid devices, EEPROM and flash, are descendants of ROM devices. These are typically used to store code. The third hybrid, NVRAM, is a modified version of SRAM. NVRAM usually holds persistent data.

Embedded Systems

16

2.4.2 Ports Data can be sent either serially, one bit after another through a single wire, or in parallel, multiple bits at a time, through several parallel wires. Most famously, these different paradigms are visible in the form of the common PC ports “serial port” and “parallel port”. Early parallel transmission schemes often were much faster than serial schemes but at added cost and complexity of hardware. Serial data transmission is much more common in new communication protocols due to a reduction in the I/O pin count, hence a reduction in cost. Common serial protocols include SPI, and I2C. Surprisingly, serial transmission methods can transmit at much higher clock rates per bit transmitted, thus tending to outweigh the primary advantage of parallel transmission. Parallel transmission protocols are now mainly reserved for applications like a CPU bus or between IC devices that are physically very close to each other, usually measured in just a few centimeters. Serial protocols are used for longer distance communication systems, ranging from shared external devices like a digital camera to global networks or even interplanetary communication for space probes; however some recent CPU bus architectures are even using serial methodologies as well. 2.4.3 Communication Devices Embedded Systems talk with the outside world via peripherals, such as: ❏

Serial Communication Interfaces (SCI): RS-232, RS-422, RS-485, etc.



Synchronous Serial Communication Interface: I2C, SPI, PCI, etc.



Universal Serial Bus (USB), Multi Media Cards (SD Cards, Compact Flash, etc.)



Networks: Ethernet, Controller Area Network, etc.



Timers: PLL(s), Capture/Compare and Time Processing Units.



Discrete IO: aka General Purpose Input/Output (GPIO).



Analog to Digital/Digital to Analog (ADC/DAC).



Debugging: JTAG, ISP, ICSP, BDM Port, BITP and DP9 ports.

Some commonly used communication devices include I2C, SPI and PCI. I2C is a multi-master, low-bandwidth, short distance, serial communication bus protocol. Nowadays it is not only used on single boards, but also to attach low-speed peripheral devices and components to a motherboard, embedded system, or cell-phone, as the new versions provide lots of advanced features and much

Components of Embedded Systems

17

higher speed. The features like simplicity and flexibility make this bus attractive for consumer and automotive electronics. 2.5 CISC VS. RISC PROCESSORS Reduced instruction set computing or RISC is a CPU design strategy based on the insight that simplified instructions can provide higher performance if this simplicity enables much faster execution of each instruction. A computer based on this strategy is a Reduced Instruction Set Computer. There are many proposals for precise definitions, but the term is slowly being replaced by the more descriptive load-store architecture. Well known RISC families include DEC Alpha, AMD 29k, ARC, ARM, Atmel AVR, MIPS, PA-RISC, Power (including Power PC) and SPARC. A complex instruction set computer or CISC, is a computer where single instructions can execute several low-level operations (such as a load from memory, an arithmetic operation, and a memory store) and/or are capable of multi-step operations or addressing modes within single instructions. The term was retroactively coined in contrast to reduced instruction set computer (RISC). Before the RISC philosophy became prominent, many computer architects tried to bridge the so called semantic gap, i.e. to design instruction sets that directly supported high-level programming constructs such as procedure calls, loop control, and complex addressing modes, allowing data structure and array accesses to be combined into single instructions. Instructions are also typically highly encoded in order to further enhance the code density. The compact nature of such instruction sets results in smaller program sizes and fewer (slow) main memory accesses, which at the time resulted in a tremendous savings on the cost of computer memory and disc storage, as well as faster execution. It also meant good programming productivity even in assembly language, as high level languages such as FORTRAN or Algol were not always available or appropriate. RISC→ → CISC Migration (a) Determined by VLSI technology. (b) Software cost goes up constantly. To be convenient for programmers. (c) To shorten the semantic gap between HLL and architecture without advanced compilers. (d) To reduce the program length because memory was expensive. (e) VAX 11/780 reached the climax with >300 instructions and >20 addressing modes.

18

Embedded Systems

CISC→ → RISC Migration (a) Things changed: HLL, Advanced Compiler, Memory size, etc. (b) Finding: 25% instructions used in 95% time. (c) Size: usually