0% found this document useful (0 votes)
17 views78 pages

Chapter Three

This document discusses embedded firmware design and development. It explains that embedded firmware is the program instructions and configuration settings dumped into an embedded system's code memory, making it intelligent and able to control hardware peripherals. Embedded firmware can be developed in high-level languages like C/C++ using IDEs tailored to specific processors. The document outlines two approaches for embedded firmware design: the super loop approach suitable for non-time-critical applications, and the embedded operating system approach for more complex systems. It provides details on each approach.

Uploaded by

Yohannes Dereje
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views78 pages

Chapter Three

This document discusses embedded firmware design and development. It explains that embedded firmware is the program instructions and configuration settings dumped into an embedded system's code memory, making it intelligent and able to control hardware peripherals. Embedded firmware can be developed in high-level languages like C/C++ using IDEs tailored to specific processors. The document outlines two approaches for embedded firmware design: the super loop approach suitable for non-time-critical applications, and the embedded operating system approach for more complex systems. It provides details on each approach.

Uploaded by

Yohannes Dereje
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 78

CHAPTER-3

www. Micro Digital Ed. com


BIHE university

Software Frameworks for Real-


time and Embedded Systems

Real time and Embedded Systems

B.Sc(SE), 2023
By Mikru L

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Lesson-1 Outline
www. Micro Digital Ed. com
BIHE university

Learning objectives:
After studying this unit, you will be able to:
Explain about Real Time Operating Systems its feature
and its characteristics
Discuss about inter process communication
Discuss the different types of Real Time task scheduling
To know about dynamic allocation of task
To explain about multi tasking and concurrency issue and
fault tolerance
To describe handling resource sharing and dependencies
To describe about synchronization techniques

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
2
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Embedded Firmware Design & Development:
 The control algorithm (Program instructions) and or the
www. Micro Digital Ed. com
BIHE university

configuration settings that an embedded system developer


dumps into the code (Program) memory of the embedded
system
 It is an un-avoidable part of an embedded system.
 The embedded firmware can be developed in various methods
like
 Write the program in high level languages like Embedded C/C+
+ using an Integrated Development Environment (The IDE will
contain an editor, compiler, linker, debugger, simulator etc.
 IDEs are different for different family of processors/controllers.

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
3
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Embedded Firmware Design & Development:
www. Micro Digital Ed. com
BIHE university

 The embedded firmware is responsible for controlling the


various peripherals of the embedded hardware and generating
response in accordance with the functional requirements of the
product.
 The embedded firmware is the master brain of the embedded
system.
 The embedded firmware imparts intelligence to an Embedded
system.
 It is a onetime process and it can happen at any stage.
 The product starts functioning properly once the intelligence
imparted to the product by embedding the firmware in the
hardware.
AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
4
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Embedded Firmware Design & Development:
www. Micro Digital Ed. com
BIHE university

 The product will continue serving the assigned task till hardware
breakdown occurs or a corruption in embedded firmware.
 In case of hardware breakdown , the damaged component may
need to be replaced and for firmware corruptions the firmware
should be re-loaded, to bring back the embedded product to the
normal functioning.
 The embedded firmware is usually stored in a permanent
memory (ROM) and it is non alterable by end users.
 Designing Embedded firmware requires understanding of the
particular embedded product hardware, like

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
5
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Embedded Firmware Design & Development:
 Component interfacing, memory map details, I/O port details,
www. Micro Digital Ed. com
BIHE university

configuration and register details of various hardware chips


used
 And some programming language (either low level Assembly
Language or High level language like C/C++ or a combination
of the two)
 The embedded firmware development process starts with the
conversion of the firmware requirements into a program
model using various modeling tools.
 The firmware design approaches for embedded product is
purely dependent on the complexity of the functions to be
performed and speed of operation required.

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
6
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Embedded Firmware Design & Development
 There exist two basic approaches for the design and
www. Micro Digital Ed. com
BIHE university

implementation of embedded firmware, namely;


• The Super loop based approach
• The Embedded Operating System based approach
 The decision on which approach needs to be adopted for
firmware development is purely dependent on the complexity
and system requirements
I. The Super loop based approach
 The Super loop based firmware development approach is
Suitable for applications that are not time critical and where
the response time is not so important (Embedded systems
where missing deadlines are acceptable).
AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
7
Assembly and C Upper Saddle River, NJ 07458. • All Rights
The Super loop based approach
 It is very similar to a conventional procedural programming where the
www. Micro Digital Ed. com
BIHE university

code is executed task by task


 The tasks are executed in a never ending loop.
 The task listed on top on the program code is executed first and the tasks
just below the top are executed after completing the first task
 A typical super loop implementation will look like:
I. Configure the common parameters and perform initialization for various
hardware components memory, registers etc.
II. Start the first task and execute it
III. Execute the second task
IV. Execute the next task
V. :
VI. :
VII. Execute the last defined task
VIII. Jump back to the first task and follow the same flow.
AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
8
Assembly and C Upper Saddle River, NJ 07458. • All Rights
The Super loop based approach
Pros:
www. Micro Digital Ed. com
BIHE university

Doesn’t require an Operating System for task scheduling and


monitoring and free from OS related overheads Simple and straight
forward design
Reduced memory footprint
Cons:
Non Real time in execution behavior (As the number of tasks
increases the frequency at which a task gets CPU time for
execution also increases)
Any issues in any task execution may affect the functioning of the
product (This can be effectively tackled by using Watch Dog
Timers for task execution monitoring)
AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
9
Assembly and C Upper Saddle River, NJ 07458. • All Rights
The Embedded Operating System based approach
www. Micro Digital Ed. com
BIHE university

 The embedded device contains an Embedded Operating System


which can be one of:
 A Real Time Operating System (RTOS)
 A Customized General Purpose Operating System (GPOS)
 The Embedded OS is responsible for scheduling the execution
of user tasks and the allocation of system resources among
multiple tasks
 It Involves lot of OS related overheads apart from managing
and executing user defined tasks
 Microsoft® Windows XP Embedded is an example of GPOS
for embedded devices

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
10
Assembly and C Upper Saddle River, NJ 07458. • All Rights
The Embedded Operating System based approach
 Point of Sale (PoS) terminals, Gaming Stations, Tablet
www. Micro Digital Ed. com
BIHE university

PCs etc are examples of embedded devices running on


embedded GPOSs
 ‘Windows CE’, ‘Windows Mobile’,‘QNX’, ‘VxWorks’,
‘ThreadX’, ‘MicroC/OS-II’, ‘Embedded Linux’,
‘Symbian’ etc are examples of RTOSs employed in
Embedded Product development
 Mobile Phones, PDAs, Flight Control Systems etc are
examples of embedded devices that runs on RTOSs

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
11
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
12
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
13
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
14
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
15
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
16
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
17
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
18
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
19
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
20
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
21
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
22
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
23
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
24
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
25
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
26
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
27
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
28
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
29
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
30
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
31
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
32
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
33
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
34
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
35
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
36
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
37
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
38
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
39
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
40
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
41
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
42
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
43
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
44
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Inter-Process Communication
www. Micro Digital Ed. com
BIHE university

 Inter-process communication is used for


exchanging data between multiple threads
in one or more processes or programs.
 It is a set of programming interface
which allow a programmer to coordinate
activities among various program
processes which can run concurrently in
an operating system.
 This allows a specific program to handle
many user requests at the same time.
Approaches for Inter-Process Communication
 Here, are few important methods for inter-
process communication:
AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
45
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Inter-Process Communication
www. Micro Digital Ed. com
BIHE university

Pipes
•Pipe is widely used for communication between two related processes.
•This is a half-duplex method, so the first process communicates with
the second process.
•However, in order to achieve a full-duplex, another pipe is needed
Message Passing:
•It is a mechanism for a process to communicate and synchronize. Using
message passing, the process communicates with each other without
resorting to shared variables.
•IPC mechanism provides two operations:
•Send (message)- message size fixed or variable
•Received (message)

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
46
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Inter-Process Communication
Message Queues:
www. Micro Digital Ed. com
BIHE university

•A message queue is a linked list of messages stored


within the kernel.
•It is identified by a message queue identifier. This
method offers communication between single or multiple
processes with full-duplex capacity.
Direct Communication:
•In this type of inter-process communication process,
should name each other explicitly. In this method, a
link is established between one pair of communicating
processes, and between each pair, only one link exists.
Indirect Communication:
•Indirect communication establishes like only when
processes share a common mailbox each pair of processes
sharing several communication links.
•A link can communicate with many processes. The link
may be bi-directional or unidirectional.© 2011 Pearson Higher Education,
AVR Microcontroller and Embedded System Using 47
• Assembly and C Upper Saddle River, NJ 07458. • All Rights
Inter-Process Communication
www. Micro Digital Ed. com
BIHE university

Shared Memory:
•Shared memory is a memory shared between two or more
processes that are established using shared memory between all
the processes.
•This type of memory requires to protected from each other by
synchronizing access across all the processes.
FIFO:
•Communication between two unrelated processes.
• It is a full-duplex method, which means that the first
process can communicate with the second process, and the
opposite can also happen.
•Semaphores: A semaphore is a signaling mechanism technique.
This OS method either allows or disallows access to the
resource, which depends on how it is set up.
•Signals: It is a method to communicate between multiple
processes by way of signaling. The source process will send a
signal which is recognized by number, and the destination
process will handle
AVR Microcontroller and Embeddedit
System Using © 2011 Pearson Higher Education,
48
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
49
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
50
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
51
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
52
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
53
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
54
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
55
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
56
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
57
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
58
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
59
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
60
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
61
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
62
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
63
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
64
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
65
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
66
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
67
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
68
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
69
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
70
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
71
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
72
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
73
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
74
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
75
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
76
Assembly and C Upper Saddle River, NJ 07458. • All Rights
www. Micro Digital Ed. com
BIHE university

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
77
Assembly and C Upper Saddle River, NJ 07458. • All Rights
Reentrancy
www. Micro Digital Ed. com
BIHE university

• A function can be suspended in the middle and re-


entered(called again) before the previous execution
returns.
• A reentrant function is function that can be used buy
more than one task without fear of data corruption.
• A reentrant function can be interrupted at any time
and resumed at a later time without loss of data.
• Reentrant functions either use local variable (i.e.
CPU register or variable on the stack) or protect data
when global variables are used.
• If data corrupted when processor switches from one
task to another task, then function is non reentrant.

AVR Microcontroller and Embedded System Using © 2011 Pearson Higher Education,
78
Assembly and C Upper Saddle River, NJ 07458. • All Rights

You might also like