78
Embedded Systems By P.DEVABALAN Assistant Professor Dept.of IT N.P.R.College of Engg. & Tech.,

Embedded systems materail

Embed Size (px)

DESCRIPTION

It is the Embedded real time operating systems material

Citation preview

Page 1: Embedded systems materail

Embedded Systems

By

P.DEVABALAN

Assistant Professor

Dept.of IT

N.P.R.College of Engg. & Tech.,

Page 2: Embedded systems materail

EMBEDDED SYSTEMS

UNIT I FUNDAMENTALS OF EMBEDDED SYSTEMS 9

Definition and classification – Overview of processors and hardware units in an

embedded system – Software embedded into the system – Exemplary embedded

systems – Embedded Systems on a Chip (SOC) and the use of VLSI designed circuits.

UNIT II DEVICES AND BUSES FOR DEVICES NETWORK 9

I/O devices – Device I/O types and examples – Synchronous ISO – Synchronous and

asynchronous communications from serial devices – Examples of internal serial

communication devices – UART and HDLC – Parallel port devices – Sophisticated

interfacing features in devices/ports – Timer and counting devices – 12C, USB, CAN

and advanced I/O serial high speed buses – ISA, PCI, PCI-X, CPCI and advanced

buses.

UNIT III PROGRAMMING CONCEPTS AND EMBEDDED

PROGRAMMING IN C, C++ 9

Programming in Assembly Language (ALP) vs high level language – C program

elements – Macros and functions – Use of pointers – NULL pointers – Use of

function calls – Multiple function calls in a cyclic order in the main function pointers

– Function queues and interrupt service routines – Queue pointers – Concepts of

embedded programming in C++ – Objected oriented programming – Embedded

programming in C++ – C program compilers – Cross compiler – Optimization of

memory codes.

UNIT IV REAL TIME OPERATING SYSTEMS – PART 1 9

Definitions of process, tasks and threads – Clear cut distinction between functions –

ISRS and tasks by their characteristics – Operating system services – Goals –

Structures – Kernel – Process management – Memory management – Device

management – File system organization and implementation – I/O subsystems –

Interrupt routines handling in RTOS.

REAL TIME OPERATING SYSTEMS : RTOS task scheduling models – Handling

of task scheduling and latency and deadlines as performance metrics – Co-operative

round robin scheduling – Cyclic scheduling with time slicing (Rate monotonics cooperative

scheduling) – Preemptive scheduling model strategy by a scheduler –

Critical section service by a preemptive scheduler – Fixed (Static) real time

scheduling of tasks.

INTER PROCESS COMMUNICATION AND SYNCHRONISATION: Shared

Data problem – Use of semaphore(s) – Priority inversion problem and deadlock

situations – Inter process communications using signals – Semaphore flag or mutex as

resource key – Message queues – Mailboxes – Pipes – Virtual (Logical) sockets –

Remote Procedure Calls (RPCs).

UNIT V REAL TIME OPERATING SYSTEMS – PART 2 9

Study of micro C/OS II or VX works or any other popular RTOS – RTOS system

level functions – Task service functions – Time delay functions – Memory allocation

related functions – Semaphore related functions – Mailbox related functions – Queue

related functions – Case studies of programming with RTOS – Understanding case

definition – Multiple tasks and their functions – Creating a list of tasks – Functions

and IPCS – Exemplary coding steps.

Page 3: Embedded systems materail

TEXT BOOKS

1. Wayne Wolf, “Computer as Components – Principles of Embedded Computing

System Design”, Morgan Kaufmann Publishers, Harcourt India Private

Limited, First Indian Reprint, 2001.

2. Rajkamal, “Embedded Systems Architecture - Programming and Design”, Tata

McGraw - Hill, First reprint, 2003.

REFERENCES

1. Steve Heath, “Embedded Systems Design”, Newnes, 2nd Edition, 2003.

2. David E. Simon, “An Embedded Software Primer”, Pearson Education, First

Indian Reprint, 2000.

3. Frank Vahid and Tony Givargis, “Embedded Systems Design - A Unified

Hardware / Software Introduction”, John Wiley, 2002.

4. Heath, “Embedded System Design”, 2nd Edition, Elsevier India Private

Limited, 2005.

Page 4: Embedded systems materail

24-Nov-10 P.DEVABALAN

Asst.Prof / IT

13

SOFTWARE Components in Embedded Systems

Programming Languages: 1. Machine code

2. Assembly language

3. High level languages ie., C, C++

StethoscopeCompiler

IDEDebugger

Trace scopeLinker

LoaderAssembler

SimulatorEditorSoftware Tools:

Page 5: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

3

DRIVES

What is an Embedded System?

Embedded system is a Hardware with Software embedded in it,

for a dedicated application.

Page 6: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

4

SMART Embedded Systems …

Page 7: Embedded systems materail

24-Nov-10 P.DEVABALAN

Asst.Prof / IT

5

SMART Embedded Systems …

Page 8: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

6

SMART Embedded Systems …

Page 9: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

7

HARDWARE

Processor, RAM, ROM, ADC, DAC, Timers, Ports, etc.

APPLICATION SOFTWARE

written in Assembly, C, C++, Java, etc.

RTOS (to supervise the Application Software)

µC OS-II, Win CE, VxWorks, Embedded Linux, etc.

3 MAIN COMPONENTS of Embedded System

Page 10: Embedded systems materail

24-Nov-10 P.DEVABALAN

Asst.Prof / IT

8

• SMALL SCALE:

8/16 bit CPU, little H/w, less S/w complexity, No RTOS,

Battery operated.

• MEDIUM SCALE:

16/32 bit µC or DSPs, Complex H/w & S/w design, RTOS

Source code Engg tools, IDE.

• SOPHISTICATED:

Configurable processors, Cutting edge applications,

Highly complex H/w and S/w design,

CLASSIFICATION of Embedded Systems

Page 11: Embedded systems materail

SKILLS for Embedded System Engineer

• HARDWARE:

µP / µC, DSPs, Memories, Peripheral devices, sensors,

Computer architecture, Digital electronics, Electronic system design,

Control system, Data communication.

• SOFTWARE:

IDE - Editor, Assemblers, Compilers, Linkers, Debuggers, Simulator.

Programming languages - Assembly, C, C++, Java

RTOS – Vxworks, Win CE, RTLinux, etc.

Page 12: Embedded systems materail

24-Nov-10 P.DEVABALAN

Asst.Prof / IT

10

COMPONENTS of Embedded System Hardware

Page 13: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

11

PROCESSORS for Embedded Systems

Control

Unit

ALU

PROCESSOR

Types of Processor

• General Purpose Processor (µc, µP, DSP, EP,MP)

• Application Specific System Processor

• Multiprocessor system

• GPP/ASIP core with other hardware integrated in ASIC chip.

Page 14: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

12

OTHER HARDWARE for Embedded Systems

1. Power supply circuit

2. Memory - EPROM, RAM, EEPROM (flash), CACHE

3. I/O Ports - 8255 (PPI), 8251 (UART)

4. Timers - 8253

5. ADC / DAC - ADC0809, DAC0800

6. Display & Keyboard Controllers - 8279

7. Programmable Interrupt Controllers - 8259

Page 15: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

13

SOFTWARE Components in Embedded Systems

Programming Languages: 1. Machine code

2. Assembly language

3. High level languages ie., C, C++

StethoscopeCompiler

IDEDebugger

Trace scopeLinker

LoaderAssembler

SimulatorEditorSoftware Tools:

Page 16: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

14

Software Development Chain

Page 17: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

15

HARDWARE in Exemplary Embedded Systems

1 MBRAM

KBD & Display portsI/O Ports

YesCache Memory

1 MBROM

32 KBEEPROM

YesDAC & ADC

YesModulation / Demodulation

YesDSP instructions

RISCArchitecture

32Bus Size

Multi processor on a ChipProcessor

MOBILE PHONE

Page 18: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

16

SOFTWARE in Exemplary Embedded Systems

yesSimulator

yesSource code Engg tools

NoCross Assembler

yesCompiler

yesLocator

yesRTOS

yesIDE

yesStethoscope

NoAssembler

NoInterpreter

yesEditor

MOBILE PHONE

Page 19: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

17

Exemplary SOC for Mobile Phone

Page 20: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

18

Types of I/O Devices

Page 21: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

19

Structure of Serial Port

Page 22: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

20

Structure of Parallel Port

Page 23: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

21

BUSES for Communication

Buses

Serial Parallel

ISA, EISA, PCI, …I2C, CAN, USB, …

I2C : Bus for communication between multiple ICs.

CAN: Bus used in automobiles with centrally controlled network.

USB: Bus for communication between CPU and devices like mouse, etc.

ISA, EISA, PCI are standard buses for parallel communication used in

PCs, computer network devices, etc.

Page 24: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

22

Types of TIMERS

Timers

Hardware

Timer

Software

Timer

Page 25: Embedded systems materail

24-Nov-10 P.DEVABALAN

Asst.Prof / IT

23

Structure of Hardware Timer

Page 26: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

24

Usage of TIMERS

Time division multiplexing10

Time slicing of various tasks9

Scheduling of various tasks in RTOS8

Baud rate control for Serial communication7

Watchdog timer6

Finding time interval between two events5

Capturing the count value in timer on an event4

Initiating an Event after a comparison of preset times3

Initiating an Event after a preset time delay2

Real Time Clock (RTC) for the system1

Page 27: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

25

Programming Embedded Systems in Assy & C

5. Portability to different hardware

and OS.

4. Usage of Control structures

like if-then, do-while, for, etc.

3. Type checking eliminates errors.3. Device driver code needs only

few assembly instructions.

2. Data type declarations make

programming easy.2. Machine codes are Compact.

1. Software development cycle is short

due to usage of functions, std library

functions, modular programming

approach, Top down design, etc.

1. Full use of processor specific

instructions.

C, C++Assembly

Page 28: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

26

Programming Embedded Systems using C++

Combines the advantage of OOPS, C & Assembly.

Special features: Data Encapsulation, inheritance, etc.

Advantages : Reusability of software components.

Disadvantages: Standard C++ programming makes code complex

and lengthy, due to features like Templates, Multiple

inheritance, Exception handling, Virtual base classes,

Namespaces, etc.

Solution : Special version of C++ (Embedded C++)

has provision for selective disabling of features.

Page 29: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

27

Phases of Software Development

a) Correction of bugs

b) Addition of extra functions as per changing

environment

Support3.

The process of software

Designing, Coding and Testing.Development2.

a) Complete Specification of the System.

b) Specification of the data, functions, tasks,..

c) System behaviour

d) Constraints of Design

e) Human machine interaction

f) Expected life cycle

g) Validation criteria & time delivery schedule

Definition and Analysis

of the System

Requirement

1.

Page 30: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

28

S/w development of Typical application (Automobiles)

Development of a Embedded system in a Car to monitor

Instrument clusters, Engine performance, Automatic Gear box,

Brakes, etc., the typical code will be as follows

399Engine speed

207Automatic gear box

1925Light Control

537Coolant Temperature

4781Alarms

376Fuel

252Wake-up / Sleep down

999Odometer

557Vehicle speed

168Recording data of usage / malfunction

1254Watch

(Total 11643 LOC)

Page 31: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

29

Source Code Engineering tool

It is a tool for source code development, compiling, debugging and testing.

eg. SNiFF+ from WindRiver® Systems

Features of SNiFF+

• Comprehension, Navigation and Browsing

• Editing

• Configuring (selective disabling of C++ features)

• Compiling

• Debugging

Page 32: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

30

Code / Memory Optimization

It is a process of making the code compact and fitting into a small

memory space without affecting code performance.

Techniques for code optimization:

• Use of unsigned byte

• Avoiding std lib functions, when simple coding is possible.

• Usage of Assy code, when target processor is well known.

• Usage of Global Variable, when no chance for shared data problem.

• Reduce usage of frequent function calls.

• Usage of delete / free, to release the used memory.

• Disabling the used features of C++.

Page 33: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

31

Process / Tasks / Threads

Process : It is a sequentially running program with its state.

Task : An application consisting of tasks controlled by scheduling

mechanism of an OS.

Threads : Light weighted sub-process in application program,

controlled by process control entity.

Page 34: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

32

- Task is independent.

- Sync done by RTOS.

- Scheduler runs one

task at a time.

- ISR is independent

- Call from H/w & S/w.

- ISR has Priority.

- Each ISR has Context.

- Set of instructions for

performing an actions.

- Called by Proc/Task/ISR.

- Each Fn has a context

- Provision for nested

Function calls.

TaskISRFunction

Comparison of Function / ISR / Task

Page 35: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

33

Inter Process Communication (IPC)

Page 36: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

34

Inter Process Communication (IPC)

IPC: Some information generated by a processes / tasks, by setting / resetting

a flag / value, or generates an output so that it lets another process take

note / use of it.

Types: 1) Signal

2) Semaphores (flags, mutex, resource key, counting)

3) Queues, Pipes or Mailbox (eg. LCD display in Mobile – Time, Ph No.)

4) Sockets (eg. COM port in PC to connect modem, port 80 – web server)

5) Remote Procedure Calls (RPC) – for distributed processes

Page 37: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

35

Shared Data Problem & its Solutions

Shared Data Problem: Conflict arising on a common variable due to usage

by multiple tasks / processes on it.

Eg. Interrupt changing the subsequent bits while

processing a 32 bit data on a 8-bit CPU.

Solutions: 1) Use of modifier “Volatile”

2) Use of “Re-entrant” functions

3) Putting shared variable in circular queues

4) Disabling interrupts on execution of Critical section

5) Using Semaphores

Page 38: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

36

Semaphore & its types

Types of Semaphores: 1) Single, 2) Multiple, 3) Mutex

4) P & V 5) Counting

Page 39: Embedded systems materail

24-Nov-10 P.DEVABALAN

Asst.Prof / IT

37

GOALS of Operating System

1. Facilitating easy sharing of resource as per schedule and allocation.

2. Facilitating easy implementation of application software.

3. Optimally scheduling the processes on one / more CPU.

4. Maximizing the system performance without any security breach.

5. Providing the management functions for Processes, tasks, etc.

6. Providing the management functions for Devices, Files, etc.

7. Providing easy interface and management functions for network & protocols.

8. Providing portability of application software on different hardware.

9. Providing interoperability of application on different networks.

10. Providing common set of interfaces.

Page 40: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

38

STRUCTURE of Operating System

OS interface

OS

Hardware – OS

Interface

Hardware

System Software(with functions other than in OS)

API

Application Software

Eg. Device driver for Multimedia device

Consists of KERNEL(Operated in User and Supervisory modes)

Page 41: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

39

KERNEL of Operating System

- OS is a middle layer between Application Software & Hardware.

- It consists of KERNEL and other functions not provided by Kernel.

- KERNEL is operated in Supervisory mode and

Other functions are operated in User Mode.

KERNEL Services

Process Management

Memory Management

Inter Process Communication

I/O management

Interrupt Control

Device drivers

Page 42: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

40

Process Management in OS

A. Process Creation: Initial and Subsequent process.

B. Management of Created process:

- Processing resource requests

- Allocation of Resources (through Message / system calls)

- Controlling of process through PCB.

- Scheduling and synchronization

Process management consists of

creation, activation, running, blocking, resumption, deactivation, deletion of processes.

Page 43: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

41

Memory Management in OS

A. Memory Allocation: at the time of creation of a new process / tasks.

B. Memory Management after allocation:

- Fixed block allocation

- Dynamic block allocation

- Dynamic page allocation

- Dynamic data memory allocation

- Dynamic address reallocation

- Multiprocessor memory allocation

Page 44: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

42

Device Management in OS

A. Manages Physical / Virtual devices (eg. Pipes & sockets).

B. Three standard approach to three types of device drivers

a) Programmed I/O poling

b) Interrupt driven through ISR

c) DMA

C. Functions of Device manager

It includes function like Device detection & addition, device allocation and

registration, device sharing, device buffer management, device access

management.

Page 45: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

43

File System Organization & Implementation

- File is a named entity stored on secondary storage device.

- It contains data in different formats.

- Both real and Virtual files (Pipe) are managed.

Functions to Organize Files in systematic way:

Open

Write

Read

Seek

Close

Page 46: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

44

Real Time Operating System (RTOS)

RTOS is an OS for Embedded system

for response time and event controlled processes.

RTOS Services:

• Basic OS functions - PM, RM, MM, DM, FSM, I/o, etc.

• RTOS main functions - RT task scheduling and latency control

• Time management - Time Allocation, time slicing & monitoring for efficiency.

• Predictability - Predicting time behaviour and initiation of task

synchronization

• Priorities Management - Allocation and Inheritance

• IPC - Synchronization of Tasks using IPC.

Page 47: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

45

Why need RTOS?

• Small scale embedded system

never use RTOS.

• Instead of functions in RTOS,

standard lib functions in C can

be used.

eg. malloc(), free(),

fopen(), fclose(), etc.

• When efficient scheduling in

needed for multitasks with

time constraints.

• Task synchronization is

needed.

• Interrupt latency Control is

essential.

Occasions for NO need of RTOSReasons for need of RTOS

Page 48: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

46

RTOS Task Scheduling Models

• Task scheduler fns are designed with

predefined time-out delays.

• WC latency is deterministic, because

the max delay is predefined.

• Cyclic Co-op Schd, Pre-emp Schd,

Fixed time Schd, Dynamic RT Schd

uses this strategy.

C. Control-data flow strategy

• Interrupt occurrences are predictable.

• Task control not deterministic.

Eg.network. (Packet arrival not predictable)

• Pre-emptive scheduler adopts this

strategy.

B. Data flow strategy

• Complete control of i/p and o/ps.

• Co-operative scheduler adopts this

strategy.

• Worst case latencies are well defined.

A. Control flow strategy

Page 49: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

47

Co-operative Round robin Scheduling

Other Types of Co-operative scheduling: i) using ordered list.

ii) using time slicing with timers

Dis-advantages: Longer execution time of a low priority task makes a higher

priority task wait until it finishes.

Page 50: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

48

Pre-emptive Scheduling

Page 51: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

49

Other Scheduling techniques and Critical Section

Critical Section: It is an important portion of a task, which should not be

blocked as it uses a shared variable.

Here, Pre-emptive scheduling leads to conflict.

Other Scheduling

Techniques: 1) Fixed real time scheduling of Tasks

2) Probabilistic timed Petrinets

3) Multi Thread Graphs (MTG)

Page 52: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

50

RTOS - Real Time Operating System

• A Real-Time Operating System (RTOS) is an operating system

(OS) intended for real-time applications in Embedded systems.

• A key characteristic of real-time operating systems is the level of

its consistency concerning the amount of time it takes to accept

and complete an application's task.

• A real-time OS has an advanced algorithm for scheduling.

• Key factors in an real-time OS are a minimal interrupt latency and

a minimal thread switching latency.

Page 53: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

51

Basic functions of RTOS

Page 54: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

52

Need for Tested RTOS

While designing a complex embedded systems, we need a tested bug

free codes for the following.

• Multiple task functions in C or C++.

• Real time clock based software timers (RTCSWT).

• Software for Co-operative scheduler.

• Software for a Pre-emptive scheduler.

• Device drivers and Device managers.

• Functions for Inter Process Communications.

• Network functions

• Error handling functions and exception handling functions.

• Testing and System debugging software.

A readily available RTOS package provides the above functions and a

lot of time is saved for coding the same.

Page 55: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

53

Options in RTOS

Options

for

RTOS

Own RTOS

Linux

Based

RTOS

µC/ OS-II(Freeware)

PSoSVxWorksNucleus

Win CEPalm OS

Page 56: Embedded systems materail

24-Nov-10 P.DEVABALAN

Asst.Prof / IT

54

µC/OS-II (MUCOS)

• µC/OS-II is Free Open-source RTOS designed by Jean J. Labrosse

in 1992.

• µC/OS-II is intended for Non-commercial use.

• µC/OS-II codes are in C and few CPU specific modules are in ASSY.

• µC/OS-II code Port on MANY Processors that are commonly used in

ES design.

Page 57: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

55

Features of µC/OS-II

• µC/OS-II is a Scalable OS.

• µC/OS-II uses Pre-emptive Scheduler (for multitasking).

• µC/OS-II has System level functions.

• µC/OS-II has Task service functions.

• µC/OS-II has Task delay functions.

• µC/OS-II has Memory allocation functions.

• µC/OS-II has IPC functions.

• µC/OS-II has Semaphore, Queue, Mailbox functions.

when OS or OS_ used as prefix, it denotes a function / variable

is a µC/OS-II function or variable.

Eg. OSTaskCreate() ---→ µC/OS-II function for TASK CREATION.

Page 58: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

56

Source code files of µC/OS-II

A. Processor dependent source files

C file for ISR and RTOS timersOs_tick.c

Processor C codes fileOs_cpu_c.c

Assy code for task switching functions (68HC12)Os_cpu-a.s12

Kernel building configuration fileOs_cfg.h

Processor definition header fileOs_cpu.h

Page 59: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

57

Source code files of µC/OS-II (contd..)

For RTOS task related functionsOs_task.c

For Memory partitioningOs_mem.c

For Semaphore related functionsOs_sem.c

For RTOS coreOs_core.c

For RTOS timerOs_time.c

For Queue related functionsOs_q.c

MUCOS header fileUcos.ii.c

MUCOS header fileUcos.ii.h

B. Processor independent source files

Page 60: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

58

RTOS System level functions

The System level functions are

Macro to disable all interruptsOS_ENTER_CRITICAL

Just after the start of ISR codesvoid OSIntEnter (void)

before return form the ISR codesVoid OSIntExit (void)

Macro to enable all interruptsOS_EXIT_CRITICAL

To initialize System timer ticksvoid OSTickInit (void)

After OSInit() and task creating functionsvoid OSStart (void)

At the beginning prior to OSStart()void OSInit (void)

Page 61: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

59

Task Service functions

These functions are used to create task, suspend and resume, and

time setting and retrieving functions.

When system time is to be setvoid OSTimeset (..)

Find present count when time is readUnsigned int OSTimeGet (void)

Called for resuming a blocked taskunsigned byte OSTaskResume (..)

Called for blocking a taskunsigned byte OSTaskSuspend (..)

Must call before running a taskunsigned byte OSTaskCreate (…)

Page 62: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

60

Time Delay functions

MUCOS Time delay functions for the tasks are

Time delay to block a taskvoid OSTimeDlyHMSM (…)

To resume a task after a preset delayunsigned byte OSTimeDlyResume (…)

To delay a task by count-1 valuevoid OSTimeDly (…)

Page 63: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

61

Memory related functions

MUCOS memory related functions for the tasks are

To find pointers of memory blocks

and data structuresunsigned byte OSMemQuery (..)

To return a pointer of memory blockunsigned byte OSMemPut (…)

To find the pointer of memory control blockvoid *OSMemGet (..)

To create and initialize memory partitionOSMem *OSMemCreate (…)

Page 64: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

62

Semaphore related functions

When a semaphore created by OS and used a resource acquiring key, it must

be initialized with “1” to indicate the resource is available.

MUCOS Semaphore related functions for the tasks are

If SemVal = 0 or more, increments, and

makes a semaphore again not pending.unsigned byte OSSemPost (…)

To check whether SemVal > 0unsigned short OSSemAccept (..)

To get semaphore informationunsigned byte OSSemQuery (…)

To check whether a semaphore is pending void OSSemPend (..)

To create and initialize a semaphoreOS_Event OSSemCreate (…)

Page 65: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

63

Other functions

Apart from the previous said functions, MUCOS has functions related to

• Mailbox

• Queue

Page 66: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

64

Automatic Chocolate Vending Machine (ACVM)

Page 67: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

65

Applications

• Medical instrumentation

• Military applications

• Aerospace research

• Robotics

• Consumer Electronics

• Industrial Applications

• Automobiles

• Telecommunication

Page 68: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

66

Breakthrough in Embedded System Designs

Page 69: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

67

According to analyst firm,

the embedded system opportunity is expected to touch

• US$ 360 billion (in terms of devices)

• US$ 36 billion (up from the existing US$ 2 billion).

Experts also predict that there will be a ten-fold increase in the number of

people employed in the embedded systems industry,

from the current 60,000 professionals to over six lakh people by 2015.

- Source: NASSCOM

Market Potential for Embedded Systems

Page 70: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

68

Embedded Systems Companies in Bangalore

Perfect E Com Solution Pvt Ltd.Datum Technologys (India) LtdiTech Workshop Pvt. Ltd.iBilt Technologies Ltd

KPIT Infosystems LtdWebspectrum Software Pvt.

Ltd.Global Software Initiatives Pvt.

Ltd.Intrepid Solutions Private Ltd

Learnet India Ltd.Binary Semantics Ltd.Java Softech Pvt. Ltd.Worldwide Infotech Inc.

Gateway WebSystems Pvt. Ltd.Datum Technologys (India) LtdSDI Infotech Pvt. Ltd.IQura Technologies Pvt. Ltd.

SolutionNet India Pvt. Ltd.Cybersol Technologies Pvt LtdPolaris Software Lab LtdVirgosys Software Pvt. Ltd.

NetmumbaiBinary Semantics Ltd.Parsec Technologies (India)

Ltd.Karishma Software Ltd.

MindEdge SolutionsKale Consultants LtdGlobal Automation (Mphasis-BFL Ltd

Rhombus Technologies Pvt.

Ltd.Mphasis-BFL LtdSurya Soft-Tech LtdDatamation Consultants Pvt.

Ltd.

Kale Consultants LtdSurya Soft-Tech LtdCompucom Software Ltd.Optimal Infotech Pvt. Ltd.

Convergent Communications (India) Pvt. Ltd.

Koenig Solutions Pvt. Ltd.Datamation Consultants Pvt. Ltd.

Vision Comptech Integrators

Ltd

Infobahn (India) Pvt. Ltd.Nihar Infoway Ltd.Click Technologies (I) Pvt. Ltd.Sadhanasoft

Page 71: Embedded systems materail

24-Nov-10 P.DEVABALAN Asst.Prof / IT

69

References

1. Rajkamal, Embedded Systems Architecture, Programming and Design,

TMH, First reprint Oct. 2003

2. David E.Simon, An Embedded Software Primer, Pearson Education Asia,

First Indian Reprint 2000.

3. www.embedded.com

4. www.micrcontroller.com

Page 72: Embedded systems materail

Unit-I Introduction to Embedded Systems

Part-A (2 Marks)

1. Define a System. 2. What is an embedded system? 3. What are the main components of an embedded system? 4. Define embedded microcontroller. 5. What are the various classifications of embedded systems? 6. What are the two essential units of a processor on a embedded system? 7. What does the execution unit of a processor in a embedded system do? 8. Give examples for general purpose processor. 9. Define microprocessor. 10. When is Application Specific System processors (ASSPs) used in an embedded system? 11. What is the need for LCD and LED displays? 12. Define ROM image. 13. Define device driver. 14.Name some of the software‟s used for the detailed designing of an embedded system. 15. What are the various models used in the design of a embedded system? 16. Give some examples for small scale embedded systems. 17. Give some examples for medium scale embedded systems. 18. Give some examples for sophisticated embedded systems. 19. Name some components available in an exemplary SoC-Smart Card? 20. What is an assembler?

Part – B 1. List the hardware units that must be present in the embedded systems. (16) 2. a. Explain the Exemplary applications of each type of embedded system. (08) b.Explain the different program layers in the embedded software and also the process of converting a “C” program into the file for ROM image with suitable block diagrams. (08) 3. Explain the Embedded System on Chip (SoC) & in VLSI circuit (16) 4. a. Explain the various form of memories present in a system (08) b. Explain the software tools in designing of an embedded system. (08)

Page 73: Embedded systems materail

Unit-II Devices and Buses for Devices Network

Part -A (2 Marks) 1. Define synchronous communication. 2. Define iso-synchronous communication. 3. What are the two characteristics of synchronous communication? 4. Give examples for serial UART input and serial UART output devices. 5. What are the three ways of communication for a device? 6. Expand a) SPI b) SCI 7. Explain any two forms of a counter. 8. Define software timer. 9. What is I2C? 10. What are the bits in I2C corresponding to? 11. What is a CAN bus? Where is it used? 12. What is USB? Where is it used? 13. What are the two standards of USB available? 14. What are the features of the USB protocol? 15. Explain briefly about PCI and PCI/X buses. 16. Why are SPCI parallel buses important? 17. Define half-duplex communication. 18. Define full duplex communication. 19. Define Real Time Clock (RTC)? 20. Define Time-out or Time Overflow?

Part – B 1. a. Explain the parallel port devices. (08) b. Explain the sophisticated interfacing features in device ports. (08) 2. Explain the timer and counting devices. (16) 3. a. Explain the signal using a transfer of byte when using the I2C bus and also the format of bits at the I2C bus with diagram. (08) b. Explain CAN bus. (08) 4. Explain the following parallel communication devices: a. ISA bus (08) b. PCI and PCI/X (08) 5. a. Explain the internal serial communication devices. (08) b. Tabulate the applications of timing devices. (08)

Page 74: Embedded systems materail

Unit – III Programming Concepts and Embedding Programming in C,C++

Part – A(2 marks) 1. What is High-level language? 2. What is Development Cycle? 3. Define In-line assembly. 4. What is Object oriented programming? 5. Define Class. 6. What is a Scalar data type? 7. What is a Reference data types? 8. Define Local variable. 9. Define NULL function. 10. What is a Runtime Library? 11.What is Multiple Inheritance? 12. Define Exception handling. 13. What is IO stream? 14. What is a Foundation class? 15. What is a Class library? 16. Define Modularity and Robustness 17. What is Platform Independence? 18. What is a Preprocessor Directive? 19. Define include file and header file 20. What is a Data structure? 21. Define passing the value. 22. Define passing the reference. 23. What is a Queue? 24. What is a Stack? 25. Define List. 26. What is an ordered list? 27. Define Source code engineering tool? 28. What is an Optimization of Memory?

Part – B 1. a. Tabulate program elements: Macros and Functions and their uses. (08) b. Explain the use of pointers, NULL pointers. (08) 2. a. Explain the multiple function calls in the cyclic order in the main. Also write the advantages of building ISR queues. Explain it. (08) b. Explain the „C‟ program compiler and cross compiler. (08) 3. a. Explain the optimization of memory codes. (08) B.Explain in detail about embedded programming in C++. (08) 4. a. Explain the function pointers, function queues and ISR queues. (08) b. Discuss the advantages of high level language. (08)

Page 75: Embedded systems materail

Unit – IV Real time Operating Systems – Part -1

Part – A (2 Marks) 1. Define process. 2. Define task. 3. Define Task Control Block (TCB) 4. Define Task state. 5. What is a thread? 6. Define Synchronization. 7. Define Inter process communication 8. What is shared data problem? 9. Define Semaphore. 10. Define Mutex. 11. What is counting semaphore? 12. What is Buffer? 13. Define P and V semaphores. 14. What is Priority inversion? 15. What is Deadlock situation? 16. Define Message Queue. 17. Define Mailbox and Pipe. 18. Define Socket. 19. Define Remote Procedure Call.

Part – B 1. a. Explain the goals of operating system services. (08) b. Explain the three alternative systems in three RTOS for responding a hardware source call with the diagram. (08) 2. Explain the scheduler in which RTOS insert into the list and the ready task for a. sequential execution in a co-operative round robin model. (08) b. Explain the fifteen point strategy for synchronization between the processes, ISRs, OS functions and tasks for resource management. (08) 3. a. Explain the critical section service by a preemptive scheduler. (08) b. Explain the Rate Monotonic Co-operative scheduling. (08)

Page 76: Embedded systems materail

Unit – V Real time Operating Systems – Part -2

Part – A( 2 marks) 1. Name any two important RTOS. 2. What is meant by well tested and debugged RTOS? 3. What is sophisticated multitasking embedded system? 4. Name any two mailbox related functions. 5. Name any two queue related functions for the inter task communications. 6. Name some application for the Vx Works RTOS. 7. How is Vx Works TCB helpful for tasks? 8. What are the various features of Vx Works? 9. What is an active task in the context of Vx Works? 10. What are the task service functions supported by Vx Works? 11. Name any four interrupt service functions supported by Vx Works? 12. Name some of the inter process communication function. 13. Name some of the inter process communication function used for messaging 14. What are Vx Works pipes? 15. What is signal servicing function? 16. What are the different types of scheduling supported by Vx Works? 17. How are pending tasks handled in Vx Works?

Part – B 1. Draw and explain basic system of an Automatic chocolate vending system. (16) 2. Discuss with the diagram task synchronization model for a specific application. (16) 3. Explain the RTOS programming tool MicroC/OS-II. (16) 4. a. Explain the features of Vx Works. (08) b. Explain the case study of an embedded system for a smart card. (08)

Page 77: Embedded systems materail

2007 ANNA UNIVERSITY CHENNAI B.TECH INFORMATION TECHNOLOGY

EMBEDDED SYSTEMS QUESTION PAPER

Course: B.Tech B.Tech Information Technology University/board: Anna University Chennai

Time: Three hours Maximum : 100 marks

Answer ALL questions

PART A – (10X2=20 MARKS)

1. Define system on chip( SOC) with an example.

2. Give any two uses of VLSI designed circuits.

3. Expand and explain HDLC.

4. What are the characteristics of PCI bus?

5. Why do you need a cross compiler?

6. What are the advantages of building ISR queues?

7. Explain the objectives of Kernel.

8. What are the uses of semaphores?

9. What is the meaning of Task Service functions?

10. What are the queue related functions?

PART B – (5 X 16 =80 Marks)

11. (a) (i) Explain the various forms of memories present in a system. (8)

(ii) List the hardware unit that must be present in the embedded systems.(8)

Or

(b) (i) Explain the different program layers in the embedded software and also

the process of converting a “C” program into the file for ROM image with suitable block diagrams. (8)

(ii) Give a brief note on Exemplary Applications of each type of Embedded

system. (8)

Page 78: Embedded systems materail

12. (a) (i) What are the characteristics taken into consideration when interfacing a

device and a port? (8)

(ii) What are the Sophisticated Interfacing features in Device Ports? (8)

Or

(b) (i) Tabulate uses of Timer device with applications and explanations. (8)

(ii) Explain the signals during a transfer of a byte when using the I2C bus and

also the format of the bits at the I2C bus with diagrams. (8)

13. (a) (i) Tabulate program elements: Macros and functions and their uses.. (8)

(ii) Explain the use of pointers, NULL pointers. (8)

Or

(b) (i) What are the advantages of using multiple function calls in cyclic order in

the main? Also write the advantages of building ISR queues? (4+4)

(ii) What are the programming advantages of C++? What are the

disadvantages of C++? (4+4)

14. (a) (i) List the goals of Operating system services . (8)

(ii) Explain three alternative systems in three RTOSs for responding to a

hardware source call with diagrams. (8)

Or

(b) (i) What are the 15 points strategy must be taken into account for designing

the code for synchronization between the processes, ISRs, OS functions and tasks and for resource management?

(8)

(ii) Explain a scheduler in which the RTOS inserts into a list the ready tasks

for sequential execution in a cooperative round robin model. (8)

15. (a) Draw and explain basic system (ACVS) of an Automatic Chocolate Vending

Machine. (16)

Or

(b) Discuss with a diagram Task synchronization model for a specific

application. (16)