embedded system 10ee665 -...

62
Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS Subject Code : 10EE665 IA Marks : 25 No. of Lecture Hrs./ Week : 04 Exam Hours : 03 Total No. of Lecture Hrs. : 52 Exam Marks : 100 PART -A UNIT -1 & 2 CONCEPT OF EMBEDDED SYSTEM DESIGN: Components, classification, skills required.Embedded Micro controller cores: Architecture of 6808 and 6811.Embedded Memories ROM variants, RAM. Applications of embedded system: Examples of Embedded systems SOC for cellless bar code scanner. 10 Hours UNIT -3 TECHNOLOGICAL ASPECTS OF EMBEDDED SYSTEM: Interfacing between analog and digital blocks, Signal conditioning, digital signal processing, DAC & ADC interfacing, Sample & hold, multiplexer interface Internal ADC interfacing (excluding 6805 & 6812), Data Acquisition System and Signal conditioning using DSP. 10 Hours UNIT -4 DESIGN TRADE OFFS DUE TO PROCESS INCOMPATIBILITY, THERMAL CONSIDERATIONS: Issues in embedded system design. Design challenge, design technology, trade offs. Thermal considerations. 6Hours PART -B UNIT -5 & 6 Software aspects of Embedded Systems, real time programming Languages, operating systems. Programming concepts and embedded programming in C. Round Robin, Round Robin with interrupts, function queue-scheduling architecture, Real time OS architecture, selecting architecture. Introduction to RTOS. 12 Hours

Upload: ngokhue

Post on 17-Mar-2018

304 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Department of EEE, SJBIT Page 1

EMBEDDED SYSTEMS

Subject Code : 10EE665 IA Marks : 25

No. of Lecture Hrs./ Week : 04 Exam Hours : 03

Total No. of Lecture Hrs. : 52 Exam Marks : 100

PART -A

UNIT -1 & 2

CONCEPT OF EMBEDDED SYSTEM DESIGN: Components, classification, skills required.Embedded

Micro controller cores: Architecture of 6808 and 6811.Embedded Memories ROM variants,

RAM. Applications of embedded system: Examples of Embedded systems SOC for cellless bar code

scanner. 10 Hours

UNIT -3

TECHNOLOGICAL ASPECTS OF EMBEDDED SYSTEM: Interfacing between analog and digital

blocks, Signal conditioning, digital signal processing, DAC & ADC interfacing, Sample & hold,

multiplexer interface Internal ADC interfacing (excluding 6805 & 6812), Data Acquisition System and

Signal conditioning using DSP. 10 Hours

UNIT -4

DESIGN TRADE OFFS DUE TO PROCESS INCOMPATIBILITY, THERMAL

CONSIDERATIONS: Issues in embedded system design. Design challenge, design technology, trade offs.

Thermal considerations. 6Hours

PART -B

UNIT -5 & 6

Software aspects of Embedded Systems, real time programming Languages, operating systems.

Programming concepts and embedded programming in C. Round Robin, Round Robin with interrupts,

function queue-scheduling architecture, Real time OS architecture, selecting architecture. Introduction

to RTOS. 12 Hours

Page 2: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 2

UNIT -7 & 8

Subsystem interfacing with external systems user interfacing, Serial I/O devices, Parallel port interfaces:

Input switches, Key boards and Memory interfacing.

Case study: Embedded velocity PID controller, PI controller with a PWM actuator. 14Hours

TEXT BOOKS:

1. Embedded Microcomputer systems: Real time interfacing-Valvano, J.W, Cengage

Learning,2nd Edition 5th Indian reprint,2009

2. The Art of Designing Embedded systems-Ganssle, Jack, Newness

Page 3: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 3

CONTENT

Sl.NO UNITS Page No.

1 & 2 CONCEPT OF EMBEDDED SYSTEM DESIGN 4-18

3 TECHNOLOGICAL ASPECTS OF EMBEDDED SYSTEM 19-30

4 DESIGN TRADE OFFS DUE TO PROCESS

INCOMPATIBILITY, THERMAL CONSIDERATIONS

32-44

5 & 6 SOFTWARE ASPECTS OF EMBEDDED SYSTEMS, REAL

TIME PROGRAMMING LANGUAGES, OPERATING

SYSTEMS

45-58

7 & 8 SUBSYSTEM INTERFACING WITH EXTERNAL SYSTEMS

USER INTERFACING

59-61

Page 4: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 4

UNIT - 1 & 2

PART – A

CONCEPT OF EMBEDDED SYSTEM DESIGN: Components, classification, skills

required. Embedded Micro controller cores: Architecture of 6808 and 6811. Embedded

Memories ROM variants, RAM, Applications of embedded system: Examples of Embedded

systems SOC for cell less bar code scanner. 10 Hours

COMPONENTS OF AN EMBEDDED SYSTEM

An embedded system has three main components: Hardware, Software and real time

operating system

i) Hardware

• Power Supply

• Processor

• Memory

• Timers

• Serial communication ports

• Output/Output circuits

• System application specific circuits

ii) Software: The application software is required to perform the series of tasks.

An embedded system has software designed to keep in view of three constraints:

• Availability of System Memory

• Availability of processor speed

• The need to limit power dissipation when running the system continuously in

cycles of wait for events, run , stop and wake up.

iii) Real Time Operating System: (RTOS) It supervises the application software

and provides a mechanism to let the processor run a process as per scheduling and

do the switching from one process (task) to another process.

Classification

We can classify embedded systems into three types as follows.

Page 5: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 5

1. Small Scale Embedded Systems: These systems are designed with a single 8- or 16-bit

microcontroller; they have little hardware and software complexities and involve board-level

design. They may even be battery operated. When developing embedded software for these, an

editor, assembler and cross assembler, specific to the microcontroller or processor used, are the

main programming tools. Usually, ‗C‘ is used for developing these systems. ‗C‘ program

compilation is done into the assembly, and executable codes are then appropriately located in the

system memory. The software has to fit within the memory available and keep in view the need

to limit power dissipation when system is running continuously.

2. Medium Scale Embedded Systems: These systems are usually designed with a single or few

16- or 32-bit microcontrollers or DSPs or Reduced Instruction Set Computers (RISCs). These

have both hardware and software complexities. For complex software design, there are the

following programming tools: RTOS, Source code engineering tool, Simulator, Debugger and

Integrated Development Environment (IDE). Software tools also provide the solutions to the

hardware complexities. An assembler is of little use as a programming tool. These systems may

also employ the readily available ASSPs and IPs (explained later) for the various functions—for

example, for the bus interfacing, encrypting, deciphering, discrete cosine transformation and

inverse transformation, TCP/IP protocol stacking and network connecting functions. [ASSPs and

IPs may also have to be appropriately configured by the system software before being integrated

into the system-bus.]

Page 6: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 6

3. Sophisticated Embedded Systems: Sophisticated embedded systems have enormous

hardware and software complexities and may need scalable processors or configurable

processors and programmable logic arrays. They are used for cutting edge applications that need

hardware and software co-design and integration in the final system; however, they are

constrained by the processing speeds available in their hardware units. Certain software

functions such as encryption and deciphering algorithms, discrete cosine transformation and

inverse transformation algorithms, TCP/IP protocol stacking and network driver functions are

implemented in the hardware to obtain additional speeds by saving time. Some of the functions

of the hardware resources in the system are also implemented by the software. Development

tools for these systems may not be readily available at a reasonable cost or may not be available

at all. In some cases, a compiler or retargetable compiler might have to be developed for these.

Skills Required

An embedded system designer has to develop a product using the available tools within the given

specifications, cost and time frame.

1. Skills for Small Scale Embedded System Designer: Author Tim Wilmshurst in the book

referred above (see page 4), has said that the following skills are needed in the individual or team

that is developing a small-scale system: ―Full understanding of microcontrollers with a basic

knowledge of computer architecture, digital electronic design, software engineering, data

communication, control engineering, motors and actuators, sensors and measurements, analog

electronic design and IC design and manufacture‖. Specific skills will be needed in specific

situations. For example, control engineering knowledge will be needed for design of control

systems and analog electronic design knowledge will be needed when designing the system

interfaces. Basic aspects of the following topics will be described in this book to prepare the

designer who already has a good knowledge of the microprocessor or microcontroller to be used.

Computer architecture and organization.

Memories.

Memory allocation.

Interfacing the memories.

Burning (a term used for porting) the executable machine codes in PROM or ROM.

Use of decoders and demultiplexers.

Direct memory accesses.

Ports.

Device drivers in assembly.

Simple and sophisticated buses.

Timers.

Interrupt servicing mechanism.

C programming elements.

Memory optimization.

Page 7: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 7

Selection of hardware and microcontroller.

Use of ICE (In-Circuit Emulators), cross-assemblers and testing equipment.

Debugging the software and hardware bugs by using test vectors.

A designer interested in small-scale embedded systems may not need at all concepts of interrupt

latencies and deadlines and their handling, the RTOS programming tools.

2. Skills for Medium Scale Embedded System Designer: ‗C‘ programming and RTOS

programming and program modeling skills are a must to design a medium-scale embedded

system. Knowledge of the following becomes critical.

Tasks and their scheduling by RTOS.

Cooperative and preemptive scheduling.

Inter processor communication functions.

Use of shared data, and programming the critical sections and re-entrant functions.

Use of semaphores, mailboxes, queues, sockets and pipes.

Handling of interrupt- latencies and meeting task deadlines.

Use of various RTOS functions.

Use of physical and virtual device drivers.

A designer must have access to an RTOS programming tool with Application Programming

Interfaces (APIs) for the specific microcontroller to be used. Solutions to various functions like

memory allocation, timers, device drivers and interrupt handing mechanism are readily available

as the APIs of the RTOS. The designer needs to know only the hardware organization and use of

these APIs. The microcontroller or processor then represents a small system element for the

designer and a little knowledge may suffice.

3. Skills for Sophisticated Embedded System Designer: A team is needed to co-design and

solve the high level complexities of the hardware and software design. An embedded system

hardware engineer should have full skills in hardware units and basic knowledge of ‗C‘, RTOS

and other programming tools. Software engineer should have basic knowledge in hardware and a

thorough knowledge of ‗C‘, RTOS and other programming tools. A final optimum design

solution is then obtained by system integration.

Micro controller cores: Architecture of 6808 and 6811

Architecture of 6808

Page 8: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 8

The 6808 is an advanced 8-bit MCU IP Core with highly sophisticated, on chip peripheral

capabilities. 6808 soft core is binary-compatible with the industry standard 68HC08 8-bit

microcontroller and can achieve a performance 45-100 million instructions per second. There are

two configurations of DF6808: Harvard where data and program buses are separated and von

Neumann with common program and data bus DF6808 has FAST architecture that is 3.2 times

faster compared to original implementation. Core in standard configuration has integrated on

chip major peripheral function. The 6808 Microcontroller Core contains full-duplex UART

(Asynchronous serial communications interface (SCI), and Synchronous Serial Peripheral

Interface SPI.

The main 16-bit, free-running timer system has implemented two input capture lines and two

output-compare lines. Self-monitoring circuitry is included on-chip to protect against system

errors. A computer operating properly (COP) watchdog system protects against software failures.

An illegal opcode detection circuit provides a nonmaskable interrupt if illegal opcode is

detected. Two software-controlled power-saving modes, WAIT and STOP, are available to

Page 9: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 9

conserve additional power. These modes make the DF6808 IP Core especially attractive for

automotive and battery-driven applications.

DF6808 is fully customizable, which means it is delivered in the exact configuration to meet

users requirements. There is no need to pay extra for not used features and wasted silicon. It

includes fully automated test bench with complete set of tests allowing easy package validation

at each stage of SoC design flow.

Features

FAST architecture, 3.2 times faster than the original implementation

Software compatible with industry standard 68HC08

Configurable Harvard or Von Neumann architectures

64 bytes of System Function Registers space (SFRs)

Up to 64k bytes of Program Memory

Up to 64k bytes of Data Memory

De-multiplexed Address/Data Bus to allow easy connection to memory

Two power saving modes: STOP, WAI

Ready pin allows Core to operate with slow program and data memories

Fully synthesizable, static synchronous design with no internal tri-states

No internal reset generator or gated clock

Scan test ready

Technology independent HDL source code

Core can be fully customized

800 MHz virtual clock frequency compared to original implementation

6811: 8-bit FAST Microcontrollers Family

Document contains brief description of 6811 core functionality. The 6811 is a advanced 8-bit

MCU IP Core with highly sophisticated, on chip peripheral capabilities. 6811 soft core is

binary-compatible with the industry standard 68HC11 8-bit microcontroller and can achieve a

performance 45-100 million instructions per second. DF6811 has FAST architecture that is 3.8

times faster compared to original implementation. Core in standard configuration has integrated

on chip major peripheral function.

There are two serial interfaces: an asynchronous serial communications interface (SCI) and a

separate synchronous serial peripheral interface (SPI).

Page 10: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 10

The main 16-bit, free-running timer system has implemented three input capture lines, five

output-compare lines, and a real-time interrupt function. An 8-bit pulse accumulator subsystem

can count external events or measure external periods. Self-monitoring circuitry is included on-

chip to protect against system errors. A computer operating properly (COP) watchdog system

protects against software failures. An illegal opcode detection circuit provides a non-maskable

interrupt if illegal opcode is detected. Two software-controlled power-saving modes, WAIT and

STOP, are available to conserve additional power. These modes make the DF6811 IP Core

especially attractive for automotive and battery-driven applications. The DF6811 have built in

the development support features designed into DF6811. The LIR signal is intended as a

debugging aid. This signal is driven to active low for the first bus cycle of each new instruction,

making it easy to reverse assemble (disassemble) instructions from the display of a logic

analyzer. DF6811 is fully customizable, which means it is delivered in the exact configuration to

meet users requirements. There is no need to pay extra for not used features and wasted silicon.

It includes fully automated testbench with complete set of tests allowing easy package validation

at each stage of SoC design flow.

Page 11: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 11

Features

FAST architecture, 3,8 times faster than the original implementation

Software compatible with industry standard 68HC11

10 times faster multiplication

16 times faster division

64 bytes of remapped System Function Registers space (SFRs)

Up to 16M bytes of Data Memory

De-multiplexed Address/Data Bus to allow easy connection to memory

Two power saving modes: STOP, WAI

Embedded Memories

In a system, there are various types of memories. Figure below shows a chart for the various

forms of memories that are present in systems.

These are as follows:

Internal RAM of 256 or 512 bytes in a microcontroller for registers, temporary data and

stack

Internal ROM/PROM/EPROM for about 4 kB to 16 kB of program (in the case of

microcontrollers). (iii) External RAM for the temporary data and stack (in most

systems).

Internal caches (in the case of certain microprocessors).

EEPROM or flash (in many systems saving the results of processing in nonvolatile

memory: for example, system status periodically and digital-camera images, songs, or

speeches after a suitable format compression).

External ROM or PROM for embedding software (in almost all no microcontroller-based

systems). (vii) RAM Memory buffers at the ports.

(viii) Caches (in superscalar microprocessors).

Page 12: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 12

Table gives the functions assigned in the embedded systems to the memories. ROM or PROM or

EPROM embeds the embedded software specific to the system

Random-access memory (RAM) is a form of computer data storage. A random-access device

allows stored data to be accessed in very nearly the same amount of time for any storage

location, so data can be accessed quickly in any random order. In contrast, other data storage

media such as hard disks, CDs, DVDs and magnetic tape, as well as early primary memory types

such as drum memory, read and write data only in a predetermined order, consecutively, because

of mechanical design limitations. Therefore the time to access a given data location varies

significantly depending on its physical location

Applications of embedded system

Embedded Systems has witnessed tremendous growth in the last one decade. Almost all the fast

developing sectors like automobile, aeronautics, space, rail, mobile communications, and

electronic payment solutions have witnessed increased use of Embedded technologies. Greater

value to mobility is one of the prominent reasons for the rise and development of Embedded

technologies.

Initially, Embedded Systems were used for large, safety-critical and business-critical applications

that included

Rocket & satellite control

Energy production control

Telephone switches

Air Traffic Control

Embedded Systems research and development is now concerned with a very large proportion of

the advanced products designed in the world. In one way, embedded technologies run global

transport industry that includes avionics, space, automotive, and trains. But, it is the electrical

Page 13: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 13

and electronic appliances like cameras, toys, televisions, home appliances, audio systems, and

cellular phones that really are the visual interface of Embedded Systems for the common

consumer.

Advanced Embedded Technologies are deployed in developing

Process Controls (energy production and distribution, factory automation and

optimization) Telecommunications (satellites, mobile phones and telecom networks),

Energy management (production, distribution, and optimized use)

Security (e-commerce, smart cards)

Health (hospital equipment, and mobile monitoring)

In the last few years the emphasis of embedded technologies was on achieving feasibility, but

now the trend is towards achieving optimality. Optimality or optimal design of embedded

systems means

Targeting a given market segment at the lowest cost and delivery time possible

Seamless integration with the physical and electronic environment

Understanding the real-world constraints such as hard deadlines, reliability, availability,

robustness, power consumption, and cost

Automobile sector

Automobile sector has been in the forefront of acquiring and utilizing Embedded technology to

produce highly efficient electric motors. These electric motors include brushless DC motors,

induction motors and DC motors, that use electric/electronic motor controllers.

European automotive industry enjoys a prominent place in utilizing Embedded technology to

achieve better engine control. They have been utilizing the recent Embedded innovations such as

brake-by-wire and drive-by-wire.

Embedded technology finds immediate importance in electric vehicles, and hybrid vehicles. Here

Embedded applications bring about greater efficiency and ensure reduced pollution. Embedded

technology has also helped in developing automotive safety systems such as the

Anti-lock braking system (ABS)

Electronic Stability Control (ESC/ESP)

Traction control (TCS)

Automatic four-wheel drive

Aerospace & Avionics

Aerospace and Avionics demand a complex mixture of hardware, electronics, and embedded

software. For efficient working, hardware, electronics and embedded software must interact with

many other entities and systems. Embedded engineers confront major challenges,

Creating Embedded systems on time

Page 14: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 14

Taking the budgetary constraints into consideration

Ensuring that the complex software and hardware interactions are right

Assembling components that meet specifications and perform effectively together

Understanding the larger context of the embedded software

Adopting the latest in Embedded technology like the fly-by-wire

Telecommunications

If ever there is an industry that has reaped the benefits to Embedded Technology, for sure, it is

only Telecommunications. The Telecom industry utilizes numerous embedded systems from

telephone switches for the network to mobile phones at the end-user. The Telecom computer

network also uses dedicated routers and network bridges to route data. Embedded engineers help

in ensuring high-speed networking. This is the most critical part of embedded applications. The

Ethernet switches and network interfaces are designed to provide the necessary bandwidth.

These will allow in rapidly incorporating Ethernet connections into advanced embedded

applications.

Consumer Electronics

Consumer electronics has also benefited a lot from embedded technologies. Consumer

electronics includes

Personal Digital Assistants (PDAs)

MP3 players

Mobile phones

Videogame consoles

Digital cameras

DVD players

GPS receivers

Printers

Even the household appliances, that include microwave ovens, washing machines and

dishwashers, are including embedded systems to provide flexibility, efficiency and features. The

latest in embedded applications are seen as advanced HVAC systems that uses networked

thermostats to more accurately and efficiently control temperature.

In the present times, home automation solutions are being increasingly built on embedded

technologies. Home automation includes wired and wireless-networking to control lights,

climate, security, audio/visual, surveillance, etc., all of which use embedded devices for sensing

and controlling.

Page 15: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 15

Railroad

Railroad signaling in Europe relies heavily on embedded systems that allows for faster, safer and

heavier traffic. Embedded technology has brought a sea of change in the way Railroad Signals

are managed and Rail traffic in large volumes is streamlined.

The Embedded technology enabled Railroad Safety Equipment is increasingly being adopted by

Railway networks across the globe, with an assurance of far lesser Rail disasters to report.

VECTOR Institute prepares embedded students for the challenges associated with Railroad

industry.

Electronic payment solutions sector

In the present times there is stiff competition amongst embedded solutions providers to deliver

innovative, and high-performance electronic payment solutions that are easy to use and highly

secure. Embedded engineers knowledgeable in trusted proprietary technology develop the

secure, encrypted transactions between payment systems and major financial institutions.

The market for mobile payments systems is growing rapidly. It is driven by retailers, restaurants,

and other businesses that want to service customers anywhere, anytime. With the use of mobile

devices, mostly mobile phones becoming very popular, embedded technologies compatible with

mobile are being developed to promote payment systems.

Smart cards industry

Smart cards, though began prominently as either a debit or a credit card, are now being

introduced in personal identification and entitlement schemes at regional, national, and

international levels. Smart cards are appearing now as Citizen Cards, drivers‘ licenses, and

patient cards.

We also come across contactless smart cards that are part of ICAO biometric passports aim to

enhance security for international travel. Europe enjoys precedence in the use of Smart cards. All

the E-services (e-banking, e-health, e-training) are based on the leading edge in smart-card

related technologies.

Example of Embedded systems SOC for cell less bar code scanner.

System on chip (SoC).

Lately, embedded systems are being designed on a single silicon chip, called System on chip

(SoC). SoC is a new design innovation for embedded systems. An embedded processor is a part

of the SoC VLSI circuit. A SoC may be embedded with the following components: multiple

processors, memories, multiple standard source solutions, called IP (Intellectual Property) cores

Page 16: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 16

and other logic and analog units. A SoC may also have a network protocol embedded into it. It

may also embed an encryption function unit. It can embed discrete cosine transforms for signal

processing applications. It may embed FPGA (Field Programmable Gate Array) cores. For a

number of applications, the GPP (microcontrollers, microprocessors or DSPs) cores may not

suffice. For security applications, killer applications, smart card, video game, palm top computer,

cell phone, mobile-Internet, hand-held embedded systems, Gbps transceivers, Gigabits per

second LAN systems and satellite or missile systems, we need special processing units in a VLSI

designed circuit to function as a processor. These special units are called Application Specific

Instruction Processors (ASIP). For an application, both the configurable processors (called

FPGA cum ASIP processors) and non-configurable processors (DSP or Microprocessor or

Microcontrollers) might be needed on a chip.

Block Diagram

A barcode reader (or barcode scanner) is an electronic device for reading printed barcodes. Like

a flatbed scanner, it consists of a light source, a lens and a light sensor translating optical

impulses into electrical ones. Additionally, nearly all barcode readers contain decoder circuitry

analyzing the barcode's image data provided by the sensor and sending the barcode's content to

the scanner's output port.

Page 17: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 17

Design Considerations

Features

TMS320C54x™ DSPs

100% code-compatible with C5000 devices

16-bit, fixed-point DSPs with power dissipation as low as 40 mW

Single and multi-core products delivering 300-532 MIPS

Three power-down modes

Integrated RAM and ROM configurations

Ultra-thin packaging Audio Power Amplifier

Efficient Class-D operation

Only three external components (TPA2005D1)

Page 18: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 18

Internal gain (TPA3007D1: 12, 18, 23.6, 36dB) Independent gain control ('2005D1)

THD+N = 0.2% at 1kHz; PSRR = -73 dB ('3007D1) & -75dB ('2005D1) Touch Screen

Controller

Integrated 4-wire touch screen controller

Highly programmable

Direct battery measurement

Stereo audio DAC with 48ksps sampling rate

SPI interface Audio DAC

Accepts 16- to 24-bit data; Left, Right I2S Format; wide sampling frequency - 5kHz to

200kHz

Hardware controlled

Benefits

Audio Power Amplifier

Eliminates need for heat sink

Reduces board space

Minimizes noise

Excellent audio fidelity

Touch Screen Controller

Fully automated modes of operation

Controls resolution, speed, timing & averaging

Monitors battery voltage

High-quality audio playback

Direct serial bus connection to controller

Audio DAC

Flexible interface to processor

Simplifies system design

Minimizes noise

Page 19: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 19

UNIT - 3

PART – A

TECHNOLOGICAL ASPECTS OF EMBEDDED SYSTEM: Interfacing between analog and

digital blocks, Signal conditioning, digital signal processing, DAC & ADC interfacing, Sample

& hold, multiplexer interface Internal ADC interfacing (excluding 6805 & 6812), Data

Acquisition System and Signal conditioning using DSP.

Analog-to-digital and digital-to-analog I/O concepts

Analog refers to physical quantities that vary continuously instead of discretely. Physical

phenomena typically involve analog signals. Examples include temperature, speed, position,

pressure, voltage, altitude, etc. Microprocessors work with digital quantities (values taken from

the discrete domain). For a digital system to interact with analog systems, conversion between

analog and digital values is needed. Building blocks to perform the conversions are: (1) Digital

to analog converters (DACs), (2) Analog to digital converters (ADCs). A digital to analog

converter has a digital input that specifies an output whose value changes in steps. These step

changes are in volts or amperes. The analog to digital converter has an input that can vary from a

minimum to a maximum value of volts or amperes. The output is a digital number that represents

the input value.

Transducers

A device that converts a process variable (ex. Car speed) into an electrical signal or vice versa.

Sensors (Input transducers): Potentiometer (position); strain gauge, piezoelectric device

(force); thermistor, thermocouple (temperature); photoconductive cell, phototransistor (light);

current transformer, SENSEFET (current); microphone (sound), etc.

Actuators (Output transducers): solenoids, relays, speakers; darlington transistors, triacs, etc.

Page 20: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 20

Some common sensors

Signal Conditioning

Signal conditioning is sometimes necessary because raw sensor outputs are not always suitable

for analog-to-digital conversion.

• Amplification: Op amps are preferred because of their performance characteristics

Open Loop gain: several hundred thousand, input current ~0, output

impedance ~0.

• Filtering: LPF

Concepts and terminology

Definitions

• Offset: minimum value

• Span: maximum value – minimum value

o Some common spans:

range of 0 V to 5 V: span = 5 V

Page 21: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 21

range of –12 V to 12 V: span = 24 V

range of 4 mA to 20 mA: span = 16 mA

• Weight: The analog change corresponding to a change in a bit in the digital number.

• Step size: span / 2n (Typically, the digital representation is an unsigned n- bit integer) (n is

the number of bits in the corresponding digital code. e.g. n=0 for a 1-bit number)

• Resolution: Same as step size. Weight of the LSB.

Example: Analog signal in range +5 to -5 volts, 8- bit ADC:

Offset = – 5 V

Span = 10 V

Step size = 10 / 256 = 39.1 mV

Notice that the MSB has a weight of 5 V (= span/ 2), and the LSB has a weight of .0391 V

Equations

Analog number = (bn-1 2–1 +… b0 2-n) x step size + offset

= (digital number x step size) + offset

Digital number = (analog number – offset) / (step size)

These equations hold true as long as the numbers are within the range. If the input of an A/D is

below the minimum or above the maximum of the range, the corresponding digital value will be

minimum or maximum, respectively. In practice, extreme input swing beyond the specified

range may damage the device.

Example:

6-bit D/A converter, analog output range:-2.5 to 5 volts. Calculate the analog output when the

input is %010101 (decimal 21)

Offset: -2.5 V

Span: 7.5 V

Step size: 0.1172 V

Analog number = 21 x 0.1171 –2.5 = -0.039 V

Example: As an example the following table lists some values for -5 V to +5 V analog range to

8-bit digital conversion:

Page 22: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 22

Analog (V) Digital (hex)

-5 00

-3.75 20

-2.5 40

-1.25 60

0 80

1.25 A0

2.5 C0

3.75 E0

5-0.0391=4.961 FF

Digital-to-Analog Converters

A DAC takes an n- bit digital input and output a corresponding analog voltage. DAC systems

normally consist of three components: (a) A reference voltage, (b) The DAC itself, (c) An op

amp for output buffering.

Page 23: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 23

Many digital-to-analog converters use R-2R ladder network. Inverted ladder type of network is

shown in the figure below. The switches are analog switches controlled by digital signals. The

output voltage (V) is proportional to the binary input. Each branch of the ladder network

contributes current whose value is proportional to the bit weight of that branch. The amplifier

circuit sums the current components to produce a voltage proportional to the binary input.

Interfacing DAC to microprocessor system

DAC integrated circuits are available with different bit resolutions. In principle, any DAC can be

interfaced to any microprocessor system. In practice, some combinations of DACs and

microprocessors are easier than others and require much simpler hardware and software in the

interface. Here, interfacing a 12-bit DAC to an 8-bit microprocessor will be considered. This will

serve to show how to mate different bit resolutions with different size data buses. Also, the

importance of double buffering will be illustrated.

Page 24: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 24

The figure given above shows an interface for a microprocessor operating in expanded

multiplexed mode. The latches are used to convert a sequence of 2 bytes into one 12-bit word.

To output a 12-bit word, the microprocessor writes the data in two steps. First, it puts the upper 4

bits on the lower nibble of the data bus. Then it selects the latch address. The address decoder

decodes the address and drives the latch chip select input low. Also, the microprocessor drives

the address line A0 low so that only the 4-bit latch accepts data from the data bus. Then the

microprocessor repeats the sequence for the lower 8 bits except that it drives A0 high. The other

purpose of the latches is to provide the double buffering. The updated latch data is not

transferred to the DAC until the microprocessor drives the control line to latch in data to the

buffer in the DAC. DAC does not change its output until Ḹ is driven low. Note that this is

important when there is a change in the upper nibble.

Analog-to-Digital Converters

The function of ADCs is to quantize the analog voltage and then output the corresponding digital

code value. As with the DAC conversion, a full- scale analog voltage will be divided into 2

quantization levels or steps for an n- bit digital coding scheme. Several techniques are used to do

the conversion. Among them successive approximation which has a medium conversion speed

(nominally 20 ms) is common in computer systems.

Page 25: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 25

The ADC has a built in DAC. A sample and hold circuit stores an analog input. The ADC logic

steps through a sequence of trial-and-error guessing to find the digital equivalent of the input. It

begins the sequence by sending a digital signal that is at midrange to the DAC. The analog

output Vout from the DAC is compared to the analog input Vin from the sample-and-hold circuit.

Thus, the ADC determines whether the analog input is above, at or below half scale. It continues

determining to which half of the next range selection the analog input belongs.

Successive Approximation example

Page 26: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 26

Page 27: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 27

68HC11 A/D Converter

The 68HC11 has a built-in A/D subsystem, but it does not have a D/A, although it can easily be

interfaced to one. External D/A converter such as DAC0808 ( 8-bit D/A) can be used. 68HC11

uses an A/D which in turn uses a D/A to generate internal signals as part of the process to

convert analog to digital. This is common to many types of A/Ds.

68HC11 supports 8 input ADC channels

Channels are located on port E (Channel 0 on PE0, Channel 1 on PE1, etc.)

In performing A/D conversions, 4 conversions are performed as a "block," each taking 32

cycles -- 128 cycles total

Control registers:

o OPTION ($ 1039): ADPU and CSEL bits

o ADCTL ($ 1030): Control and status information

o ADR1 - ADR4 ($ 1031 - $1034): Result registers

Page 28: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 28

More detailed description for conversion

DAC is replaced by a series of capacitors that are charged to the voltages that correspond

to the weights of each bit

• During the sample mode, the capacitors are charged. This total charge is proportional to

the input analog signal. For the duration of the conversion process, this total charge

remains conserved. The A/D switches to the hold mode and then to the approximation

mode. The approximation mode is a sequence of successive approximation steps that

switches different capacitors to modify the input voltage to the comparator. The result of

each step sets or resets a corresponding bit in a successive approximation register (SAR).

• VRH is normally set to the signal maximum (analog value for digital data $FF) and VRL is

set to minimum (analog value of $00). However, VRH should not be higher than 6 V and

VRL should not be lower than ground, and VRH - VRL should be greater than 2.5 V.

• 8-bit outputs from four successive conversions are placed into analog data registers

ADR1-ADR4.

68HC11 A/D related Registers

The MCU on the EVB has an 8-bit register at location $1030 that is the A/D‘s control and status

register (ADCTL). Bits 0-5 are the control bits and may be read from or written to. Bit 6 is not

used and is always read as logic 0. Bit 7 is a status bit and can only be read. Data written to this

bit is ignored.

Page 29: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 29

Data Acquisition Systems (DAS)

Data acquisition systems (DAS) interface between the real world of physical parameters, which

are analog, and the artificial world of digital computation and control. With current emphasis on

digital systems, the interfacing function has become an important one; digital systems are used

widely because complex circuits are low cost, accurate, and relatively simple to implement. In

addition, there is rapid growth in the use of microcomputers to perform difficult digital control

and measurement functions. Computerized feedback control systems are used in many different

industries today in order to achieve greater productivity in our modern industrial societies.

Industries that presently employ such automatic systems include steel making, food processing,

paper production, oil refining, chemical manufacturing, textile production, cement

manufacturing, and others. The devices that perform the interfacing function between analog

and digital worlds are analog-to-digital (A/D) and digital-to-analog (D/A) converters, which

together are known as data converters. Some of the specific applications in which data converters

are used include data telemetry systems, pulse code modulated communications, automatic test

systems, computer display systems, video signal processing systems, data logging systems, and

sampled data control systems. In addition, every laboratory digital multimeter or digital panel

meter contains an A/D converter.

BASIC DATA ACQUISITION SYSTEM

Besides A/D and D/A converters, data acquisition and distribution systems may employ one or

more of the following circuit functions:

• transducers,

• amplifiers,

• filters,

• nonlinear analog functions,

• analog multiplexers,

• sample-holds.

The interconnection of these components is shown in the diagram of the data acquisition portion

of a computerized feedback control system in Figure 1. The input to the system is a physical

parameter such as temperature, pressure, flow, acceleration, and position, which are analog

quantities. The parameter is first converted into an electrical signal by means of a transducer;

once in electrical form, all further processing is done by electronic circuits.

Next, an amplifier boosts the amplitude of the transducer output signal to a useful level for

further processing (Transducer outputs may be microvolt or millivolt level signals, which are

then amplified to 1 to 10 V levels. Furthermore, the transducer output may be a highimpedance

signal, a differential signal with common-mode noise, a current output, a signal superimposed on

a high voltage, or a combination of

Page 30: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 30

these. The amplifier, in order to convert such signals into a high-level voltage, may be one of

several specialized types. The amplifier is frequently followed by a low-pass active filter that

reduces high-frequency signal components, unwanted electrical interference noise, or electronic

noise from the signal. The amplifier is sometimes also followed by a special nonlinear analog

function circuit that performs a nonlinear operation on the high-level signal. Such operations

include squaring, multiplication, division, rms conversion, log conversion, or linearization. The

processed analog signal next goes to an analog multiplexer, which switches sequentially between

a number of different analog input channels each input is in turn connected to the output of the

multiplexer for a specified period of time by the multiplexer switch. During this connection time,

a sample-hold circuit acquires the signal voltage and then holds its value while an A/D converter

converts the value into digital form. The resultant digital word goes to a computer data bus or to

the input of a digital circuit.

Thus the analog multiplexer, together with the sample hold, time shares the A/D converter with a

number of analog input channels. The timing and control of the complete DAS is done by a

digital circuit called a programmer sequencer, which in turn is under the control of the computer.

In some cases, the computer itself may control the entire DAS. While this is perhaps the most

commonly used DAS configuration, there are alternative ones. Instead of multiplexing high-level

signals, low-level multiplexing is sometimes used with the amplifier following the multiplexer.

In such cases, just one amplifier is required, but its gain may have to be changed from one

channel to the next during multiplexing. Another method is to amplify and convert the signal into

digital form at the transducer location and send the digital information in serial form to the

computer. Here, the digital data must be converted to parallel form and then multiplexed onto the

computer data bus.

Page 31: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 31

Signal conditioning using DSP

The use of a digital signal processor offers the designer the ability to compensate for, or to

completely avoid, the limitations outlined in the last section. The effects of residual null signal

and transducer non-linearity can be compensated by digital error correction, while the use of

digital demodulation techniques make the system insensitive to spurious phase shifts up to ±90

degrees. A software correction algorithm is easily able to compensate for static errors in the

output measurement by means of a software correction map. The software determines a

correction offset y interpolation between the nearest points in the map and applies it to the

measurement – a simple process taking only a few CPU cycles. The correction map is stored in

internal non-volatile memory, and can be programmed during routine calibration of the

transducer.

Page 32: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 32

UNIT – 4

DESIGN TRADE OFFS DUE TO PROCESS INCOMPATIBILITY, THERMAL

CONSIDERATIONS:

Issues in embedded system design. Design challenge, design technology, tradeoffs. Thermal

considerations.

Issues in embedded system design

Embedded computers typically have tight constraints on both functionality and implementation.

In particular, they must guarantee real time operation reactive to external events, conform to size

and weight limits, budget power and cooling consumption, satisfy safety and reliability

requirements, and meet tight cost targets.

Real time/reactive operation

Real time system operation means that the correctness of a computation depends, in part, on the

time at which it is delivered. In many cases the system design must take into account worst case

performance. Predicting the worst case may be difficult on complicated architectures, leading to

overly pessimistic estimates erring on the side of caution. The Signal Processing and Mission

Critical example systems have a significant requirement for real time operation in order to meet

external I/O and control stability requirements.

Reactive computation means that the software executes in response to external events. These

events may be periodic, in which case scheduling of events to guarantee performance may be

possible. On the other hand, many events may be aperiodic, in which case the maximum event

arrival rate must be estimated in order to accommodate worst case situations. Most embedded

systems have a significant reactive component.

Design challenge:

Worst case design analyses without undue pessimism in the face of hardware with

statistical performance characteristics e.g., cache memory.

Small size, low weight

Many embedded computers are physically located within some larger artifact. Therefore, their

form factor may be dictated by aesthetics, form factors existing in pre-electronic versions, or

having to fit into interstices among mechanical components. In transportation and portable

Page 33: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 33

systems, weight may be critical for fuel economy or human endurance. Among the examples, the

Mission Critical system has much more stringent size and weight requirements than the others

because of its use in a flight vehicle, although all examples have restrictions of this type.

Design challenges:

Non-rectangular, non-planar geometries.

Packaging and integration of digital, analog, and power circuits to reduce size.

Page 34: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 34

Safe and reliable

Some systems have obvious risks associated with failure. In mission-critical applications such as

aircraft flight control, severe personal injury or equipment damage could result from a failure of

the embedded computer. Traditionally, such systems have employed multiply-redundant

computers or distributed consensus protocols in order to ensure continued operation after an

equipment failure.

However, many embedded systems that could cause personal or property damage cannot tolerate

the added cost of redundancy in hardware or processing capacity needed for traditional fault

tolerance techniques. This vulnerability is often resolved at the system level as discussed later.

Design challenge:

Low-cost reliability with minimal redundancy.

Harsh environment

Many embedded systems do not operate in a controlled environment. Excessive heat is often a

problem, especially in applications involving combustion (e.g., many transportation

applications). Additional problems can be caused for embedded computing by a need for

protection from vibration, shock, lightning, power supply fluctuations, water, corrosion, fire, and

general physical abuse. For example, in the Mission Critical example application the computer

must function for a guaranteed, but brief, period of time even under non-survivable fire

conditions.

Design challenges:

Accurate thermal modeling.

De-rating components differently for each design, depending on operating environment.

Cost sensitivity

Even though embedded computers have stringent requirements, cost is almost always an issue

(even increasingly for military systems). Although designers of systems large and small may talk

about the importance of cost with equal urgency, their sensitivity to cost changes can vary

dramatically. A reason for this may be that the effect of computer costs on profitability is more a

function of the proportion of cost changes compared to the total system cost, rather than

compared to the digital electronics cost alone. For example, in the Signal Processing system cost

sensitivity can be estimated at approximately $1000 (i.e., a designer can make decisions at the

$1000 level without undue management scrutiny). However, with in the Small system decisions

Page 35: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 35

increasing costs by even a few cents attract management attention due to the huge multiplier of

production quantity combined with the higher percentage of total system cost it represents.

Design challenge:

Variable "design margin" to permit tradeoff between product robustness and aggressive

cost optimization.

Design challenge

Design matrics:

A Design metric is a measure of implementations features such as cost, size, performance and

power. Embedded system

must cost less

must be sized to fit on a single chip.

must perform in real time (response time.

The embedded system designer must be designed to meet the desired functionality. Apart

meeting the functionality, should also consider optimizing numerous design metrics.

Common design metrics that a design engineer should consider:

NRE (non recurring engineering Cost) : The one time monetary cost of designing the

system.

Unit cost: Monetary cost of manufacturing each copy of the system, excluding NRE cost.

Size: physical space required by the system. Often measured in terms of bytes in case of

software, and no. of gates in terms of hardware.

Performance: execution/response time of the system.

Power: The amount of power consumed by the system, which may define lifetime of the

battery and cooling requirement of IC. More power means more heat.

Flexibility: ability to change the functionality of the system.

Time to prototype: time needed to build a working system w/o incurring heavy NRE.

Time to market: time required to develop & released to the market.

Maintainability: ability to modify the system after its release to the market.

Correctness: our confidence that we have implemented system‘s functionality correctly.

Safety: probability that the system does not cause any harm.

Metrics typically compete with one another: improving one often leads to worsening of

another

Page 36: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 36

Design metric competition

Page 37: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 37

Time to Market Design Metric:

The time to market: Introducing an embedded system early to the market can make big

difference in terms of system‘s profitability

Market windows generally will be very narrow, often in the order of few months.

Missing this window can mean significant loss in sales.

Time to Market

(A) Market window and simplified revenue model for computing revenue loss

Let‘s investigate the loss of revenue that can occur due to delayed entry of a product in the

market. We can use a simple triangle model y axis is the market rise, x axis to represent the point

of entry to the market. The revenue for an on time market entry is the area of the triangle labeled

‗on time‘ and the revenue for a delayed entry product is the area of the triangle labeled

‘Delayed‘. The revenue loss for a delayed entry is the difference of these triangle‘s areas.

% revenue loss = ((on time – Delayed)/on time)*100 %

The area of on time triangle = ½ * base * height

W -- height the market raise

D -- Delayed entry (in terms of weeks or months)

2W – product‘s life time

Area of on time triangle = ½*2W*W

Area of delayed triangle=1/2*(W-D+W)*(W-D)

Page 38: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 38

%age revenue loss = (D (3W- D)/2W*W) * 100 %

Ex: product‘s life time is 52 weeks

Delay of entry to the market is 4 weeks

Percentage revenue loss = 22%

The NRE and Unit cost Design metrics:

Unlike other design metric the best technology choice will depend on the no of units.

Tech: A would result in NRE cost $2000 unit cost $100

B $30000 $30

C 100000 $2

Total cost= NRE cost + unit cost* no of units

Per product cost = total cost/no of units

= NRE cost/no of units + unit cost

The performance Design metric:

Performance of a system is a measure of how long the system takes to execute our desired tasks.

There are several measures of performance. The two main measures are:

Latency or response time

Throughput : no of tasks that are processed in unit

‗ speed up‘ is a method of comparing performance of two systems

Speed up of A over B = performance of A/performance of B.

DESIGN TECHNOLOGY:

Design technology involves the manner in which we convert our concept of desired system

functionality into an implementation. We must not only design the implementation to optimise

design metrics, but we must do so quickly.

Variations of a top-down design process have become popular in the past decade, an ideal form

of which is illustrated in the figure. The designer refines the system through several abstraction

levels. At the system level the designer describes the desired functionality in an executable

language like C. This is called system specification.

Page 39: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 39

The designer refines this specification by distributing portions of it among several general and/or

single purpose processors, yielding behavioural specifications for each processor.

The designer refines these specifications into register-transfer (RT) specifications by converting

behaviour on general-purpose processors to assembly code, and by converting behaviour on

single purpose processors to a connection of register-transfer components and state machines.

The designer then refines the RT level specification into a logic specification.

Finally, the designer refines the remaining specifications into an implementation consisting of

machine code for general purpose processors and a design gate level net list for single purpose

processors.

Deal top-down design process, and productivity improvers .

There are three main approaches to improving the design process for increased productivity,

which we label as compilation/synthesis, libraries/IP, and test/verification. Several other

approaches also exist.

Compilation/Synthesis

Compilation/Synthesis lets a designer specify desired functionality in an abstract manner, and

automatically generates lower-level implementation details. Describing a system at high

Page 40: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 40

abstraction levels can improve productivity by reducing the amount of details, often by an order

of magnitude, that a design must specify.

A logic synthesis tool converts Boolean expressions into a connection of logic gates (called a net

list). A register-transfer (RT) synthesis tool converts finite-state machines and register-transfers

into a data path of RT components and a controller of Boolean equations. A behavioral synthesis

tool converts a sequential program into finite-state machines and register transfers. Likewise, a

software compiler converts a sequential program to assembly code, which is essentially register-

transfer code. Finally, a system synthesis tool converts an abstract system specification into a set

of sequential programs

on general and single-purpose processors.

The relatively recent maturation of RT and behavioral synthesis tools has enabled a unified view

of the design process for single-purpose and general-purpose processors. Design for the former is

commonly known as ―hardware design,‖ and design for the latter as ―software design.‖ In the

past, the design processes were radically different – software designers wrote sequential

programs, while hardware designers connected components.

Page 41: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 41

The co-design ladder: Recent maturation of synthesis enables a unified view of hardware

and software.

Libraries/IP

Libraries involve re-use of pre-existing implementations. Using libraries of existing

implementations can improve productivity if the time it takes to find, acquire, integrate and test a

library item is less than that of designing the item oneself. A logic-level library may consist of

layouts for gates and cells. An RT-level library may consist of layouts for RT components, like

registers, multiplexors, decoders, and functional units. A behavioral-level library may consist of

commonly used components, such as compression components, bus interfaces, display

controllers, and even general purpose processors. The advent of system-level integration has

caused a great change in this level of library.

Test/Verification

Test/Verification involves ensuring that functionality is correct. Such assurance can prevent

time-consuming debugging at low abstraction levels and iterating back to high abstraction levels.

Page 42: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 42

Simulation is the most common method of testing for correct functionality, although more formal

verification techniques are growing in popularity. At the logic level, gate level simulators

provide output signal timing waveforms given input signal waveforms.

Likewise, general-purpose processor simulators execute machine code. At the RT-level,

hardware description language (HDL) simulators execute RT-level descriptions and provide

output waveforms given input waveforms. At the behavioral level, HDL simulators simulate

sequential programs, and co-simulators connect HDL and general purpose processor simulators

to enable hardware/software co-verification. At the system level, a model simulator simulates the

initial system specification using an abstract computation model, independent of any processor

technology, to verify correctness and completeness of the specification.

More productivity improvers

There are numerous additional approaches to improving designer productivity. Standards focus

on developing well-defined methods for specification, synthesis and libraries. Such standards can

reduce the problems that arise when a designer uses multiple tools, or retrieves or provides

design information from or to other designers. Common standards include language standards,

synthesis standards and library standards.

Languages focus on capturing desired functionality with minimum designer effort. For example,

the sequential programming language of C is giving way to the object oriented language of C++,

which in turn has given some ground to Java. As another example, state-machine languages

permit direct capture of functionality as a set of states and transitions, which can then be

translated to other languages like C.

Frameworks provide a software environment for the application of numerous tools throughout

the design process and management of versions of implementations. For example, a framework

might generate the UNIX directories needed for various simulators and synthesis tools,

supporting application of those tools through menu selections in a single graphical user interface.

Thermal considerations

Embedded Applications differ from the typical desktop, server and mobile markets. Some of the

different requirements for embedded applications include higher ambient temperatures, need for

higher max component temperature spec, low platform power, long life support, small form

factors, and extended usage conditions (24 x 7 x 365 operation). Due to these differences there

are special considerations for component and system level thermal solution design. Thermal

solution design requires an engineer to fully understand the system and various form factor

boundary conditions and component level attributes. This document will define thermal cooling

Page 43: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 43

schemes: passive, active and fan less thermal solutions and their difference via the three modes

of heat transfer (conduction, convection, and radiation). The thermal performance metrology will

be explained, using a thermal resistance calculation and how to apply to Intel components. The

methodology will highlight typical Intel component specifications such as TJ-MAX, TCASE-

MAX, TAMBIENT and Thermal Design Power (TDP). In addition some thermal features such

as the Digital Thermal Sensor (DTS) and Thermal Monitor will be explained.

Computing platform component power has decreased as a result of silicon technology

improvement. However, it is still critical to cool the components to adequately ensure a product‘s

long-life reliability. In embedded applications, there are challenges which are more demanding

than the general computing systems such as desktops, notebooks, and workstations/servers. The

major differences are the target usage model and operating environment. Typically, embedded

applications are in harsh environments, such as outdoors, factory assembly lines, and telecomm

base stations. Conversely, the usual desktop, mobile, and workstation/ server are typically

deployed in homes, offices, and data centers where there are controlled environmental

conditions.

Intel provides a wide variety of embedded processors and chipsets that have features and

specifications that are suited for embedded markets. These components typically have high

maximum temperatures limits, long life availability and features such as Digital Thermal Sensor

and Enhanced Intel SpeedStep® Technology. All of these features will aid the embedded thermal

engineer in designing robust thermal solutions for Intel Architecture.

Cooling Methods

There are three basic types of thermal solutions for electronics cooling: passive thermal

solutions, active thermal solutions and fan less thermal solutions. The type of cooling solution

used in an embedded system will vary depending on the form factor, component specifications,

and boundary conditions. All thermal solutions rely on the three modes of heat transfer to

dissipate the heat from the component: conduction, convection and radiation.

Three Modes of Heat Transfer

Conduction

Thermal conduction is the process in which thermal energy transfers through matter, from a

region of higher temperature to lower temperature and acts to equalize the temperature

difference. It can also be described as the heat energy transferred from one material to another by

direct contact.

Convection

Page 44: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 44

Convection is the transfer of thermal energy between two surfaces as a consequence of a relative

velocity between them. The most practical application is where one surface is a solid and the

other is a fluid.

Radiation

Radiation cooling is the transfer of heat by electromagnetic emission, primarily in the infrared

wavelengths. While the transfer of energy by conduction and convection requires the presence of

a material medium, radiation does not. In fact, radiation transfer occurs most effectively in a

vacuum.

Active Thermal Solutions

An active thermal solution is a heat sink that incorporates a fan attached directly to it. This is the

most common type of thermal solution for desktop computers. In general embedded applications

do not use this type of thermal solution. These solutions usually require more height above the

motherboard than embedded form factors can provide.

Passive Thermal Solution

Passive thermal solutions are the most common type of thermal solution for embedded

applications. This type of thermal solution employs a solid metal heat sink attached to the heat

dissipating component and then with system airflow the heat is removed. Since the airflow is

provided by system fan(s), the velocity tends to be much lower than that of an active heat sink,

resulting in a lower convection heat transfer coefficient. There could be obstacles, like

motherboard components, that are placed between the system fan and the passive heat sink,

which creates a resistance to the forced air flow from system fan. In turn, this usually requires a

larger heat sink to achieve the same performance, since the thermal solution must rely on more

conductive heat transfer. The advantage of passive thermal solutions is that they can be used in

form factors where the z-height above the motherboard is limited. In some usage models, the

fans are grouped into an easily removable tray fastened to the system chassis air inlet, which

allows for swapping of defective fan(s) from the system chassis.

Fan less Thermal Solution

A fan less thermal solution refers to a solution that does not use a fan (system or component

level) to provide airflow. The only airflow is induced by the buoyancy effect where hot air

moves opposite the direction of gravity and cool air moves towards the direction of gravity. This

air movement is created by the difference in air density and the resulting velocity is very low.

Page 45: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 45

PART – B

UNIT - 5 & 6

Software aspects of Embedded Systems : Real time programming Languages, operating

systems, Programming concepts and embedded programming in C, Round Robin, Round Robin

with interrupts, function queue-scheduling architecture, Real time OS architecture, selecting

architecture. Introduction to RTOS.

Real time programming Languages

Real-time programming has always been one of the most challenging programming disciplines.

Real-time programming requires comprehensive command of sequential programming,

concurrency, and, of course, time. Real-time programming has many application domains. In this

chapter, however, we structure our discussion around digital control systems for the following

two reasons. Firstly, digital control systems represent a large portion of real-time software in a

diverse set of industries. Examples include automotive power train control systems, aircraft flight

control systems, electrical drive systems in paper mills, or process control systems in power

plants and refineries.

Real-time programs must guarantee response within strict time constraints. Often real-

time response times are understood to be in the order of milliseconds and sometimes

microseconds. In contrast, a non-real-time system is one that cannot guarantee a response time in

any situation, even if a fast response is the usual result. The use of this word should not be

confused with the two other legitimate uses of 'real-time'. In the domain of simulations, the term

means that the simulation's clock runs as fast as a real clock would; and in the domain of data

transfer, media processing and enterprise systems, the term is used to mean 'without perceivable

delay'. Real-time software may use one or more of the following: synchronous programming

languages, real-time operating systems, and real-time networks, each of which provide essential

frameworks on which to build a real-time software application. A real-time system may be one

where its application can be considered (within context) to be mission critical. The anti-lock

brakes on a car are a simple example of a real-time computing system — the real-time constraint

in this system is the time in which the brakes must be released to prevent the wheel from locking.

Real-time computations can be said to have failed if they are not completed before their deadline,

where their deadline is relative to an event. A real-time deadline must be met, regardless

of system load. Most embedded systems have to function under certain real-time constraints.

Developing applications for such systems requires programming languages and abstractions

which are substantially different from those used for developing desktop applications. The aim of

this module is to introduce different real-time programming models and programming languages

corresponding to each of these model.

Page 46: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 46

Operating Systems

Operating system consists of a set of programs (software) that manages the hardware and

provides an environment to run multiple application programs. The OS shares the hardware

(CPU, Memory, I/O controllers and I/O devices) among multiple application programs.

Components of an Operating System

Operating system (OS) is not a single program; it is a set of programs. However the real core of

an operating system is called Kernel. The second important program of an OS is User Interface

(UI) program. Old operating systems used to have only Command Line user Interface (CLI)

program called Shell. But all modern operating systems are coming with Graphical User

Interfaces (GUI) called Windows. All the other programs that come with the OS are utility

application programs.

The set of programs that comes with OS, and which we call OS is shown inside the dashed lines.

The most important part of the OS, is the Kernel. But just kernel alone is not enough. So OS

comes with two types of user interface programs. One is graphics based and other is command

(or text) based. Besides these user interface programs, OS also includes many utility programs,

to create and list file, directories.

Following are the typical services provided by the Kernel to the system applications:

Page 47: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 47

File Services

I/O Services

Multi-processing services

Multi-threading services

Memory allocation and mapping services

Signal/Event services

Inter Process Communication and Synchronization services

Time services

Network communication services

Kernel has got the following main responsibilities for the programs:

Loading a program into memory by allocating required memory

Providing a CPU time slice (i.e scheduling) for the above program to run

Providing the services (system calls) so that the program can use these services

Once the program is finished, unloading the application from memory and freeing the

memory

Kernel performs the scheduling during the following events:

During timer interrupt from a timer device

During system call

File Services

Using the file services one can write a program to do the following things:

Opening an existing file

Creating new a file

Writing data to a file sequentially or to selected areas of file

Reading data from a file sequentially or from selected areas of a file

Reading the attributes (details such size, owner, permissions etc..) of a file

Deleting a file

Changing the attributes of file

Opening an existing directory

Creating a new directory

Read the contents of a directory

Closing the file or directory

Page 48: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 48

I/O Services

Using the file services one can write a program to do the following things:

Opening an I/O device

Reading from I/O device

Writing to I/O device

Reading the settings of an I/O device

Modifying the settings of an I/O device

Closing the I/O device

Programming concepts and embedded programming in C

Assembly language coding of an application has the following advantages:

It gives a precise control of the processor internal devices and full use of processor

specific features in its instruction set and its addressing modes.

The machine codes are compact. This is because the codes for declaring the conditions,

rules, and data type do not exist. The system thus needs a smaller memory. Excess

memory needed does not depend on the programmer data type selection and rule-

declarations. It is also not the compiler specific and library functions specific.

Device driver codes may need only a few assembly instructions. For example, consider a

small embedded system, a timer device in a microwave oven or an automatic washing

machine or an automatic chocolate vending machine. Assembly codes for these can be

compact and precise, and are conveniently written.

It becomes convenient to develop the source files in C or C++ or Java for complex systems

because of the following advantages of high-level languages for such systems.

The development cycle is short for complex systems due to the use of functions

(procedures), standard library functions, modular programming approach and top down

design. Application programs are structured to ensure that the software is based on sound

software engineering principles.

o Modular programming approach is an approach in which the building blocks are

reusable software components. Consider an analogy to an IC (Integrated Circuit).

Just as an IC has several circuits integrated into one, similarly a building block

may call several functions and library functions. A module should however, be

well tested. It must have a well-defined goal and the well-defined data inputs and

outputs. It should have only one calling procedure. There should be one return

point from it. It should not affect any data other than that which is targeted. [Data

Page 49: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 49

Encapsulation] It must return (report) error conditions encountered during its

execution.

o Bottom up design is a design approach in which programming is first done for the

sub modules of the specific and distinct sets of actions. An example of the

modules for specific sets of actions is a program for a software timer, RTCSWT::

run. Programs for delay, counting, finding time intervals and many applications

can be written. Then the final program is designed. The approach to this way of

designing a program is to first code the basic functional modules and then use

these to build a bigger module.

o Top-Down design is another programming approach in which the main program

is first designed, then its modules, sub-modules, and finally, the functions.

Data type declarations provide programming ease. For example, there are four types of

integers, int, unsigned int, short and long. When dealing with positive only values, we

declare a variable as unsigned int. For example, numTicks (Number of Ticks of a clock

before the timeout) has to be unsigned. We need a signed integer, int (32 bit) in

arithmetical calculations. An integer can also be declared as data type, short (16 bit) or

long (64 bit). To manipulate the text and strings for a character, another data type is char.

Each data type is an abstraction for the methods to use, to manipulate, to represent, and

for a set of permissible operations.

Type checking makes the program less prone to error. For example, type checking does

not permit subtraction, multiplication and division on the char data types. Further, it lets

+ be used for concatenation. [For example, micro + controller concatenates into

microcontroller, where micro is an array of char values and controller is another array of

char values.]

Control Structures (for examples, while, do - while, break and for) and Conditional

Statements (for examples, if, if- else, else - if and switch - case) make the program-flow

path design tasks simple.

Portability of non-processor specific codes exists. Therefore, when the hardware changes,

only the modules for the device drivers and device management, initialization and locator

modules and initial boot up record data need modifications.

Page 50: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 50

Additional advantages of C as a high level languages are as follows:

1. It is a language between low (assembly) and high level language. Inserting the assembly

language codes in between is called in-line assembly. A direct hardware control is thus also

feasible by in-line assembly, and the complex part of the program can be in high-level language.

The ‗C‘ program elements, header and source files and preprocessor directives are as follows:

Any C program first includes the header and source files that are readily available.

# include ―vxWorks.h‖ /* Include VxWorks functions*/

# include ―semLib.h‖ /* Include Semaphore functions Library */

# include ―taskLib.h‖ /* Include multitasking functions Library */

# include ―msgQLib.h‖ /* Include Message Queue functions Library */

# include ―fioLib.h‖ /* Include File-Device Input-Output functions Library */

# include ―sysLib.c‖ /* Include system library for system functions */

# include ―netDrvConfig.txt‖ /* Include a text file that provides the ‗Network Driver

Configuration‘. It provides the frame format protocol (SLIP or PPP or Ethernet) description, card

description/make, address at the system, IP address (s) of the node (s) that drive the card for

transmitting or receiving from the network. */

# include ―prctlHandlers.c‖ /* Include file for the codes for handling and actions as per the

protocols used for driving streams to the network. */

Include is a preprocessor directive to include the contents (codes or data) of a file. The files that

can be included are given below. Inclusion of all files and specific header files has to be as per

requirements.

Including Codes Files: These are the files for the codes already available. For example, #

include ―prctlHandlers.c‖.

Including Constant data Files: These are the files for the codes and may have the

extension‗.const‘.

Including Stings data Files: These are the files for the strings and may have the extension

‗.strings‘ or ‗.str.‘ or ‗.txt. For example, # include ―netDrvConfig.txt‖

Including initial data Files: There are files for the initial or default data for the shadow

ROM of the embedded system. The boot-up program is copied later into the RAM and

may have the extension ‗.init‘. On the other hand, RAM data files have the extension,

‗.data‘.

Including basic variables Files: These are the files for the local or global static variables

that are stored in the RAM because they do not posses the initial (default) values. The

Page 51: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 51

static means that there is a common not more than one instance of that variable address

and it has a static memory allocation. There is only one real time clock, and therefore

only one instance of that variable address. These basic variables are stored in the files

with the extension ‗.bss‘.

Including Header Files: It is a preprocessor directive, which includes the contents (codes

or data) of a set of source files. These are the files of a specific module. A header file has

the extension ‗.h‘. Examples are as follows. The string manipulation functions are needed

in a program using strings. These become available once a header file called ―string.h‖ is

included. The mathematical functions, square root, sin, cos, tan, atan and so on are

needed in programs using mathematical expressions. These become available by

including a header file, called ―math.h‖. The pre-processor directives will be ‗# include

<string.h>‘ and ‗# include <math.h>‘.

Also included are the header files for the codes in assembly, and for the I/O operations (conio.h),

for the OS functions and RTOS functions. # include ―vxWorks.h‖ is directive to compiler, which

includes VxWorks RTOS functions.

Note: Certain compilers provide for conio.h in place of stdio.h. This is because embedded

systems usually do not need the file functions for opening, closing, read and write. So when

including stdio.h, it makes the code too big.

What is the difference between inclusion of a header file, and a text file or data file or constants

file?

Consider the inclusion of netDrvConfig.txt.txt and math.h.

The header files are well tested and debugged modules.

The header files provide access to standard libraries.

The header file can include several text file or C files.

A text file is description of the texts that contain specific information.

Source files

Source files are program files for the functions of application software. The source files need to

be compiled. A source file will also possess the preprocessor directives of the application and

have the first function from where the processing will start. This function is called main function.

Its codes start with void main ( ). The main calls other functions. A source file holds the codes as

like the ones given earlier.

Page 52: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 52

Configuration files

Configuration files are the files for the configuration of the system. Recall codes in Lines.

Device configuration codes can be put in a file of basic variables and included when needed. If

these codes are in the file ―serialLine_cfg.h‖ then # include ―serialLine_cfg.h‖ will be

preprocessor directive. Consider another example. I# include ―os_cfg.h‖. It will include os_cfg

header file.

Preprocessor Directive

A preprocessor directive starts with a sharp (hash) sign. These commands are for the following

directives to the compiler for processing.

Preprocessor Global Variables: ―# define volatile boolean IntrEnable‖ is a preprocessor

directive. It means it is a directive before processing to consider IntrEnable a global

variable of boolean data type and is volatile. [Volatile is a directive to the compiler not to

take this variable into account while compacting and optimising the codes.] IntrDisable,

IntrPortAEnable, IntrPortADisable, STAF and STAI are the other global variables.

Preprocessor Constants: ―# define false 0‖ is a preprocessor directive. It means it is a

directive before processing to assume ‗false‘ as 0. The directive ‗define ‗ is for allocating

pointer value(s) in the program. Consider # define portA (volatile unsigned char *)

0x1000 and # define PIOC (volatile unsigned char *) 0x1001. 0x1000 and 0x1000 are

for the fixed addresses of portA and PIOC. These are the constants defined here for these

68HC11 registers. Strings can also be defined. Strings are the constants, for example,

those used for an initial display on the screen in a mobile system.

Preprocessor Macros: A macro is a collection of codes that is defined in a program by a name. It

differs from a function in the sense that once a macro is defined by a name, the compiler puts the

corresponding codes for it at every place where that macro name appears.

Use of data types

Whenever a data is named, it will have the address(es) allocated at the memory. The number of

addresses allocated depends upon the data type. ‗C‘ allows the following primitive data types.

The char (8 bit) for characters, byte (8 bit), unsigned short (16 bit), short (16 bit), unsigned int

(32 bit), int (32 bit), long double (64 bit), float (32 bit) and double (64 bit). [Certain compilers do

not take the ‗byte‘ as a data type definition. The ‗char‘ is then used instead of ‗byte‘. Most C

compilers do not take a Boolean variable as data type. As in second line of typedef is used to

create a Boolean type variable in the C program.] A data type appropriate for the hardware is

used. For example, a 16-bit timer can have only the unsigned short data type, and its range can

be from 0 to 65535 only. The typedef is also used. It is made clear by the following example. A

Page 53: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 53

compiler version may not process the declaration as an unsigned byte. The ‗unsigned character‘

can then be used as a data type. It can then be declared as follows:

typedef unsigned character portAdata

#define Pbyte portAdata Pbyte = 0xF1

Round-Robin

Round-robin (RR) is one of the simplest scheduling algorithms for processes in an operating

system. As the term is generally used, time slices are assigned to each process in equal portions

and in circular order, handling all processes without priority (also known as cyclic executive).

Round-robin scheduling is simple, easy to implement, and starvation-free. Round-robin

scheduling can also be applied to other scheduling problems, such as data packet scheduling in

computer networks.

In order to schedule processes fairly, a round-robin scheduler generally employs time-sharing,

giving each job a time slot or quantum[1] (its allowance of CPU time), and interrupting the job if

it is not completed by then. The job is resumed next time a time slot is assigned to that process.

In the absence of time-sharing, or if the quanta were large relative to the sizes of the jobs, a

process that produced large jobs would be favoured over other processes.

Example: If the time slot is 100 milliseconds, and job1 takes a total time of 250 ms to complete,

the round-robin scheduler will suspend the job after 100 ms and give other jobs their time on the

CPU. Once the other jobs have had their equal share (100 ms each), job1 will get another

allocation of CPU time and the cycle will repeat. This process continues until the job finishes

and needs no more time on the CPU.

Job1 = Total time to complete 250 ms (quantum 100 ms).

First allocation = 100 ms.

Second allocation = 100 ms.

Third allocation = 100 ms but job1 self-terminates after 50 ms.

Total CPU time of job1 = 250 mS

Another approach is to divide all processes into an equal number of timing quanta such that the

quantum size is proportional to the size of the process. Hence, all processes end at the same time.

Page 54: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 54

Round-Robin with Interrupts

Interrupt routines deal with the very urgent needs of devices Interrupt routines set flags to

indicate the interrupt happened main while loop polls the status of the interrupt flags and does

any follow-up processing required by a set flag.

RR with Interrupts Advantages

More control over priorities.

device routines can be serviced in any order

processor interrupt priority settings can be used

Interrupt routines get good response (low latency)

Main loop can be suspended

Interrupt routines are (must/should be) short.

Interrupt code inherently has a higher priority than task code

RR with Interrupts disadvantages

More complicated than Round-Robin

Context problems can occur saving and restoring context inside interrupts routines

becomes necessary when number of registers/resources is small.

Shared data problems

Debugging becomes more complicated.

Same latency/priority issues still exist.

Function queue-scheduling architecture

In this architecture, the interrupt routines add function pointers to a queue of function pointers

for the main function to call. What makes this architecture worthwhile is that no rule says the

main task code has to call the functions in the order that the interrupt occurred. It can call them

based on any priority scheme of your choosing. Any task code functions that need quicker

response can be executed earlier. All you need is some coding in the routines that queue up the

function pointers.

Function Queue Schedule

Every time there is an interrupt quickly collect all appropriate data.

And state that the appropriate data-handling function needs to be executed soon.

Page 55: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 55

This is done put putting a function pointer into a queue.

RTOS Architecture

The architecture of an RTOS is dependent on the complexity of its deployment. Good RTOSs are

scalable to meet different sets of requirements for different applications. For simple applications,

an RTOS usually comprises only a kernel. For more complex embedded systems, an RTOS can

be a combination of various modules, including the kernel, networking protocol stacks, and other

components as illustrated in Figure

General Architecture of RTOS

.

Kernel

An operating system generally consists of two parts: kernel space (kernel mode) and user space

(user mode). Kernel is the smallest and central component of an operating system. Its services

include managing memory and devices and also to provide an interface for software applications

to use the resources. Additional services such as managing protection of programs and

multitasking may be included depending on architecture of operating system. There are three

broad categories of kernel models available, namely:

Monolithic kernel

It runs all basic system services (i.e. process and memory management, interrupt handling and

I/O communication, file system, etc) in kernel space. As such, monolithic kernels provide rich

and powerful abstractions of the underlying hardware. Amount of context switches and

Page 56: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 56

messaging involved are greatly reduced which makes it run faster than microkernel. Examples

are Linux and Windows.

Monolithic Kernel Based Operating System`

Microkernel

It runs only basic process communication (messaging) and I/O control. The other system services

(file system, networking, etc) reside in user space in the form of daemons/servers. Thus, micro

kernels provide a smaller set of simple hardware abstractions. It is more stable than monolithic as

the kernel is unaffected even if the servers failed (i.e.File System). Examples are AmigaOS and

QNX.

Microkernel Based Operating System

Page 57: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 57

Introduction to RTOS

RTOS stands for Real time operating systems as the name suggests, there is a deadline associated

with tasks and an RTOS adheres to this deadline as missing a deadline can cause affects ranging

from undesired to catastrophic As discussed above that the embedded systems are becoming

more and more complex today and with each passing generation their intrusion in our daily lives

will become deeper. This means they will bear more and more responsibilities on their shoulders

to solve real time problems to make our life easier. But, this requires more and more complex

real time applications that RTOS will have to manage effectively.

Some of the most widely used RTOS are:

LynxOS

OSE

QNX

RTLinux

VxWorks

Windows CE

Page 58: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 58

Classification of RTOS

RTOS can be classified into three types :

Hard RTOS: These type of RTOS strictly adhere to the deadline associated with the

tasks. Missing on a deadline can have catastrophic affects. The air-bag example we

discussed in the beginning of this article is example of a hard RTOS as missing a

deadline there could cause a life.

Firm RTOS: These type of RTOS are also required to adhere to the deadlines because

missing a deadline may not cause a catastrophic affect but could cause undesired affects,

like a huge reduction in quality of a product which is highly undesired.

Soft RTOS: In these type of RTOS, missing a deadline is acceptable. For example On-

line Databases.

Features of RTOS

An RTOS must be designed in a way that it should strike a balance between supporting a rich

feature set for development and deployment of real time applications and not compromising on

the deadlines and predictability.

The following points describe the features of an RTOS:

Context switching latency should be short. This means that the time taken while saving

the context of current task and then switching over to another task should be short.

The time taken between executing the last instruction of an interrupted task and executing

the first instruction of interrupt handler should be predictable and short. This is also

known as interrupt latency.

Similarly the time taken between executing the last instruction of the interrupt handler

and executing the next task should also be short and predictable. This is also known as

interrupt dispatch latency.

Reliable and time bound inter process mechanisms should be in place for processes to

communicate with each other in a timely manner.

An RTOS should have support for multitasking and task preemption. Preemption means

to switch from a currently executing task to a high priority task ready and waiting to be

executed.

Real time Operating systems but support kernel preemption where-in a process in kernel

can be preempted by some other process.

Page 59: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 59

UNIT - 7 & 8

Subsystem interfacing with external systems user interfacing, Serial I/O devices, Parallel port

interfaces:

Input switches, Key boards and Memory interfacing.

Case study: Embedded velocity PID controller, PI controller with a PWM actuator.

14Hours

Serial I/O

Any input or output that comprises a byte, word, or longer stream that's shifted into or out of the

system a single bit at a time. Serial I/O is used mostly for data communications. It's cheaper to

run a few wires between remote devices than a parallel bus, especially since noise considerations

usually mandate level shifters on each line. But even within a computer, some serial I/O is not

unusual: the I2C bus often connects several processors on a single PCB, and serial EEPROMs

are widely used to store MAC addresses and other nonvolatile data

RS-232C

An EIA standard that defines a commonly used serial communications scheme. RS-232C is

widely used to transfer data between computers or other devices using an asynchronous serial

link at speeds ranging from 110 to 115,200 baud. The standard defines connectors, signals, signal

levels, and typical handshake.

A 'space' (logic 0) ranges from +3 to +25 V; 'marks' (1s) are -3 to -25 V. Unfortunately, the

standard permits a wide range of connections and handshaking. As a result, the two RS-232C

devices you're trying to connect might may not plug and play

RS-422

An EIA standard that defines a serial communications scheme designed for sending data over

long distances in noisy environments. RS-422 defines a serial, asynchronous, four-wire

communications link using differential signals. Two wires each are used for transmission and

reception. Polarity of the signal defines 1s and 0s: a voltage of +200 mV to +6 V is 1 ('mark'); -

200 mV to -6 V is a 0 ('space'). RS-422 supports data rates to 10 Mbps over cables up to 1200

meters long

Parallel port interfaces

An I/O channel that moves more than 1 bit at a time in or out of a computer. Usually

implemented (for outputs) as a latch connected to the data bus, enabled by a strobe decoded from

the address and control buses. Input parallel ports are made from a tristate buffer connected in a

Page 60: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 60

similar manner.

Example: A bank of LEDs connected to a computer generally interface on one or more parallel

ports.

Input switches

An input device that can take any one of two or more values. Most switches are binary: either

open or closed.

Example Dip Switch

Key boards and Memory interfacing.

When you press a key on your computer, you are activating a switch. There are many different

ways of making these switches. An overview of the construction and operation of some of the

most common types.

1. Mechanical key switches:

In mechanical-switch keys, two pieces of metal are pushed together when you press the key. The

actual switch elements are often made of a phosphor-bronze alloy with gold platting on the

contact areas. The key switch usually contains a spring to return the key to the nonpressed

position and perhaps a small piece of foam to help damp out bouncing.

Some mechanical key switches now consist of a molded silicon dome with a small piece of

conductive rubber foam short two trace on the printed-circuit board to produce the key pressed

signal.

• Mechanical switches are relatively inexpensive but they have several disadvantages.

First, they suffer from contact bounce. A pressed key may make and break contact

several times before it makes solid contact.

• Second, the contacts may become oxidized or dirty with age so they no longer make a

dependable connection.

Higher-quality mechanical switches typically have a rated life time of about 1 million

keystrokes. The silicone dome type typically last 25 million keystrokes.

2. Membrane key switches:

These switches are really a special type of mechanical switches. They consist of a three-layer

plastic or rubber sandwich.

Page 61: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 61

• The top layer has a conductive line of silver ink running under each key position. The

bottom layer has a conductive line of silver ink running under each column of keys.

• When you press a key, you push the top ink line through the hole to contact the bottom

ink line. The advantages of membrane keyboards is that they can be made as very thin,

sealed units.

They are often used on cash registers in fast food restaurants. The lifetime of membrane

keyboards varies over a wide range.

Capacitive key switches:

A capacitive key switch has two small metal plates on the printed circuit board and another metal

plate on the bottom of a piece of foam.

When you press the key, the movable plate is pushed closer to fixed plate. This changes the

capacitance between the fixed plates. Sense amplifier circuitry detects this change in capacitance

and produce a logic level signal that indicates a key has been pressed. The big advantages of a

capacitive switch is that it has no mechanical contacts to become oxidized or dirty. A small

disadvantage is the specified circuitry needed to detect the change in capacitance. Capacitive key

switches typically have a rated lifetime of about 20 million keystrokes.

Hall Effect key switches:

This is another type of switch which has no mechanical contact. It takes advantage of the

deflection of a moving charge by a magnetic field.

• A reference current is passed through a semiconductor crystal between two opposing

faces. When a key is pressed, the crystal is moved through a magnetic field which has its

flux lines perpendicular to the direction of current flow in the crystal.

• Moving the crystal through the magnetic field causes a small voltage to be developed

between two of the other opposing faces of the crystal.

This voltage is amplified and used to indicate that a key has been pressed. Hall effect sensors are

also used to detect motion in many electrically controlled machines.

Hall effect keyboards are more expensive because of the more complex switch

mechanism, but they are very dependable and have typically rated lifetime of 100 million

or more keystrokes.

Page 62: Embedded system 10EE665 - libvolume3.xyzlibvolume3.xyz/.../softwareaspectsofembeddedsystemsnotes1.pdf · Embedded system 10EE665 Department of EEE, SJBIT Page 1 EMBEDDED SYSTEMS

Embedded system 10EE665

Dept of EEE, SJBIT Page 62

The following flow chart for a procedure to detect, debounce and produce the hex code for a

pressed key.

• An easy way to detect if any key in the matrix is pressed is to output 0‗s to all rows and

then check the column to see if a pressed key has connected a low to a column.

• In the algorithm we first output lows to all the rows and check the columns over and over

until the column are all high. This is done before the previous key has been released

before looking for the next one. In the standard keyboard terminology, this is called two key

lockout.