Bal Kishore Bharti - 20 - Cse - Embedded System Assignment
Bal Kishore Bharti - 20 - Cse - Embedded System Assignment
SESSION :2023-24
Assignment of
EMBEDDED SYSTEM
Roll No.20134501020
UNIT-1
Introduction of Embedded System
Embedded Systems are omnipresent. We find everywhere – at our homes,
in our offices, in shopping malls and so on.
What is an Embedded System?
“Embedded System is Special purpose Computer.”
An embedded system can be defined as a computing device that does a
specific focused job.
An embedded system is a combination of computer hardware and software
designed for a specific function. Embedded systems may also function
within a larger system. The systems can be programmable or have a fixed
functionality.
Examples of embedded system –
Air-conditioner, VCD player, DVD player, printer, fax machine, mobile
phone etc.
Characteristics of Embedded System: -
1. Performs specific tasks: Embedded systems do a very specific task;
they cannot be programmed to do different things.
2. Low Cost: Embedded systems have very limited resources,
particularly the memory. generally, they do not have secondary
storage devices such as the CDROM or the floppy disk.
3. Time Specific: Embedded systems have to work against some
deadlines. A specific job has to be completed within a specific time.
In some embedded systems, called real-time systems, the deadlines
are stringent. Missing a deadline may cause a catastrophe-loss of life
or damage to property.
4. Low Power: Embedded systems are constrained for power. As many
embedded systems operate through a battery, the power consumption
has to be very low.
5. Minimal User Interface: Many embedded systems do not require a
complex user interface. They are often designed to operate
autonomously or with minimal user intervention.
6. High Efficiency: Embedded systems are designed to be highly
efficient in terms of processing power, memory usage, and energy
consumption. This ensures that they can perform their specific task
with maximum efficiency and reliability.
7. Highly Stable: Embedded systems are typically designed to be stable
and reliable. They are often used in applications where failure is not
an option, such as in medical devices or aviation.
8. High Reliability: Embedded systems are designed to operate reliably
and consistently over long periods. This is important in applications
where downtime can be costly or dangerous.
MP3 players
Microwave ovens
calculator
MP3 player
Mobile phones
Digital Camera
Based on Performance and micro-controller it is divided into 3 types
as follows:
Memory
Other devices
Harvard Architecture
The Harvard architecture offers separate storage and signal buses for
instructions and data. This architecture has data storage entirely contained
within the CPU, and there is no access to the instruction storage as data.
Computers have separate memory areas for program instructions and data
using internal data buses, allowing simultaneous access to both instructions
and data.
Programs needed to be loaded by an operator; the processor could not boot
itself. In a Harvard architecture, there is no need to make the two memories
share properties.
EMBEDDED SYSTEM /SOFTWARE ARCHITECTURE
Application
Programming Interface
Application Software
Communication
Software
Operating
System
ffffffffffffffffffffffffffffffffffffddd
aaaaaaaaaaaaaaaaaaaaax File
Libraries Kernal
system
Device
Manage
r
Define Requirements:
Start by clearly defining the requirements of your embedded system,
including hardware constraints, real-time requirements, and specific
features you need in your custom OS.
Hardware Compatibility:
Ensure that your custom OS is compatible with the hardware of the
embedded system. This may involve writing or porting device drivers for
the specific hardware components.
Kernel Design:
Design the core of your operating system, known as the kernel. Decide on
the architecture (monolithic, microkernel, etc.) and data structures that will
be used.
Real-Time Considerations:
If real-time capabilities are required, design and implement a real-time
scheduler to meet the system's timing constraints.
Memory Management:
Implement memory management for the embedded system, taking into
account limited memory resources. This may involve designing memory
protection mechanisms.
File System (if needed):
Develop a file system or adapt an existing one to suit the storage
requirements of your embedded system.
Communication and Interprocess Communication (IPC):
Implement communication mechanisms to facilitate interprocess
communication (IPC) between different components or tasks running on
the system.
Security:
Consider security measures, especially if the embedded system will be used
in critical applications. Implement security features to protect against
potential threats.
Development Tools:
Set up development tools and environment for building and testing the
custom OS. This includes cross-compilers, debugging tools, and emulators.
Testing and Debugging:
Rigorously test the operating system on the target hardware, using various
test cases to ensure its stability, reliability, and real-time behavior.
Documentation:
Document the design, implementation, and usage of the custom operating
system for future reference and maintenance.
Maintenance and Updates:
Plan for future maintenance and updates, as embedded systems often have
long lifecycles. Consider how you will patch and improve the OS as needed.
Licensing:
If you plan to distribute your custom OS, consider the licensing and legal
aspects. Be aware of any open-source components or licenses you use.
Optimization: Optimize the OS for performance and resource usage to
ensure that it runs efficiently on the embedded system.
Deployment:
Deploy the custom OS to the embedded system and ensure that it meets the
functional and performance requirements of the target application.
UNIT 2
EMBEDDED HARDWARE ARCHITECTURE-
32 BIT MICROCONTROLLORS
You probably already know that a microcontroller is a piece of a
semiconductor chip that does arithmetic processing and controls the circuit
through the I/O and peripheral interface. The name ‘32-bit microcontroller’
implies that the microcontroller is capable of handling arithmetic operation
for a 32-bit value. Compared to an 8-bit microcontroller, the 32-bit
microcontroller takes fewer instruction cycles to execute a function due to
its wider data bus.
With its superior performance, a 32-bit microcontroller is often built with
more peripherals and memory. For example, the NXP LPC1700 series
features 4 32-bit timers, SD/MMC, USB, Ethernet Mac, CAN, and other
peripherals, which is not possible with an 8-bit MCU.
While they boast powerful performance and are rich in peripherals, 32-bit
microcontrollers are power-hungry components. They operate at higher
frequencies that range between tens to hundreds of Mhz.
32-bit microcontrollers are also a bad fit for battery-operated circuits, such
as wireless IoT sensors. They would quickly drain the battery even when
operating at the slowest clock rate.
32-bit microcontrollers are a great choice in these circumstances:
When you need a microcontroller capable of handling intense data
processing. For example, a biometric controller that compares a fingerprint
with tens of thousands of records and responds in a split second.
When you have a complex circuit in need of a microcontroller that can
handle multiple peripherals. In such cases, it is more economical to use a
32-bit microcontroller than using a few logic ICs in the circuit.
When the code size of the program is too large for an 8-bit microcontroller.
32-bit microcontrollers are built with larger flash memory.
Assembly Language
Assembly language is introduced for providing mnemonics or symbols for
the machine level code instructions. Assembly language program is
consisting of mnemonics that is translated into machine code. A program
that is used for this conversion is known as assembler.
Assembly language is also called as low-level language because it directly
works with the internal structure of CPU. For programming in assembly
language, a programmer must have the knowledge of all the registers in a
CPU.
Different programming languages like C, C++, Java and various other
languages are called as high-level languages because they are not dealing
with the internal details of CPU.
Structure of Assembly Language
An assembly language program is a series of statements, which are either
assembly language instructions such as ADD and MOV, or statements
called directives.
An instruction tells the CPU what to do, while a directive (also called
pseudo-instructions) gives instruction to the assembler. For example, ADD
and MOV instructions are commands which the CPU runs, while ORG and
END are assembler directives. The assembler places the opcode to the
memory location 0 when the ORG directive is used, while END indicates
to the end of the source code. A program language instruction consists of
the following four fields −
[ label: ] mnemonics [ operands ] [;comment ]
A square bracket ( [ ] ) indicates that the field is optional.
The label field allows the program to refer to a line of code by name. The
label fields cannot exceed a certain number of characters.
The mnemonics and operands fields together perform the real work of the
program and accomplish the tasks. Statements like ADD A , C & MOV C,
#68 where ADD and MOV are the mnemonics, which produce opcodes ;
"A, C" and "C, #68" are operands. These two fields could contain directives.
Directives do not generate machine code and are used only by the
assembler, whereas instructions are translated into machine code for the
CPU to execute.
1.0000 ORG 0H ;start (origin) at location 0
2 0000 7D25 MOV R5,#25H ;load 25H into R5
3.0002 7F34 MOV R7,#34H ;load 34H into R7
4.0004 7400 MOV A,#0 ;load 0 into A
5.0006 2D ADD A, R5 ; add contents of R5 to A
6.0007 2F ADD A,R7 ;add contents of R7 to A
7.0008 2412 ADD A,#12H ;add to A value 12 H
8.000A 80FE HERE: SJMP HERE ;stay in this loop
9.000C END ;end of asm source file
The comment field begins with a semicolon which is a comment indicator.
Notice the Label "HERE" in the program. Any label which refers to an
instruction should be followed by a colon.
DB (Define Byte)
The DB directive is the most widely used data directive in the assembler. It
is used to define the 8-bit data. It can also be used to define decimal, binary,
hex, or ASCII formats data. For decimal, the "D" after the decimal number
is optional, but it is required for "B" (binary) and "Hl" (hexadecimal).
ORG 500H
DATA1: DB 28 ; DECIMAL (1C in hex)
DATA2: DB 00110101B ; BINARY (35 in hex)
DATA3: DB 39H ;HEX
ORG 510H
DATA4: DB "2591" ;ASCII NUMBERS
ORG 520H
DATA6: DA "MY NAME IS Michael” ; ASCII CHARACTERS
Either single or double quotes can be used around ASCII strings. DB is also
used to allocate memory in byte-sized chunks.
Assembler Directives
Some of the directives of 8051 are as follows −
ORG (origin) − The origin directive is used to indicate the beginning of the
address. It takes the numbers in hexa or decimal format. If H is provided
after the number, the number is treated as hexa, otherwise decimal. The
assembler converts the decimal number to hexa.
EQU (equate) − It is used to define a constant without occupying a memory
location. EQU associates a constant value with a data label so that the label
appears in the program, its constant value will be substituted for the label.
While executing the instruction "MOV R3, #COUNT", the register R3 will
be loaded with the value 25 (notice the # sign). The advantage of using EQU
is that the programmer can change it once and the assembler will change all
of its occurrences; the programmer does not have to search the entire
program.
END directive − It indicates the end of the source (asm) file. The END
directive is the last line of the program; anything after the END directive is
ignored by the assembler.
Labels in Assembly Language
All the labels in assembly language must follow the rules given below −
Each label name must be unique. The names used for labels in assembly
language programming consist of alphabetic letters in both uppercase and
lowercase, number 0 through 9, and special characters such as question
mark (?), period (.), at the rate @, underscore (_), and dollar($).
The first character should be in alphabetical character; it cannot be a
number.
When the reset pin is activated, the 8051 jumps to the address location 0000.
This is power-up reset. Two interrupts are set aside for the timers: one for
timer 0 and one for timer 1. Memory locations are 000BH and 001BH
respectively in the interrupt vector table.
Two interrupts are set aside for hardware external interrupts. Pin no. 12 and
Pin no. 13 in Port 3 are for the external hardware interrupts INT0 and INT1,
respectively. Memory locations are 0003H and 0013H respectively in the
interrupt vector table.
Serial communication has a single interrupt that belongs to both receive and
transmit. Memory location 0023H belongs to this interrupt.
Steps to Execute an Interrupt
When an interrupt gets active, the microcontroller goes through the
following steps −
• The microcontroller closes the currently executing instruction and saves
the address of the next instruction (PC) on the stack.
• It also saves the current status of all the interrupts internally (i.e., not on
the stack).
• It jumps to the memory location of the interrupt vector table that holds
the address of the interrupts service routine.
• The microcontroller gets the address of the ISR from the interrupt vector
table and jumps to it. It starts to execute the interrupt service subroutine,
which is RETI (return from interrupt).
• Upon executing the RETI instruction, the microcontroller returns to the
location where it was interrupted. First, it gets the program counter (PC)
address from the stack by popping the top bytes of the stack into the PC.
Then, it starts to execute from that address.
Edge Triggering vs. Level Triggering
Interrupt modules are of two types − level-triggered or edge-triggered.
Level Triggered Edge Triggered
A level-triggered interrupt module always generates an An edge-triggered interrupt module generates
interrupt whenever the level of the interrupt source is an interrupt only when it detects an asserting
asserted. edge of the interrupt source. The edge gets
detected when the interrupt source level
actually changes. It can also be detected by
periodic sampling and detecting an asserted
level when the previous sample was de-
asserted.
If the interrupt source is still asserted when the Edge-triggered interrupt modules can be acted
firmware interrupt handler handles the interrupt, the immediately, no matter how the interrupt
interrupt module will regenerate the interrupt, causing source behaves.
the interrupt handler to be invoked again.
Level-triggered interrupts are cumbersome for Edge-triggered interrupts keep the firmware's
firmware. code complexity low, reduce the number of
conditions for firmware, and provide more
flexibility when interrupts are handled.
Enabling and Disabling an Interrupt
Upon Reset, all the interrupts are disabled even if they are activated. The
interrupts must be enabled using software in order for the microcontroller
to respond to those interrupts.
IE (interrupt enable) register is responsible for enabling and disabling the
interrupt. IE is a bit addressable register.
Interrupt Enable Register
• EA - Global enable/disable.
• - - Undefined.
• ET2 – Enable Timer 2 interrupt.
• ES – Enable Serial port interrupt.
• ET1 – Enable Timer 1 interrupt.
• EX1 – Enable External 1 interrupt.
• ET0 – Enable Timer 0 interrupt.
EX0 – Enable External 0 interrupt
Imagine you are shooting at a target with a bow and arrow. How do the
arrows fly from the bow? One at a time, right? This is exactly the case with
serial communication; the data bits travel from one embedded device to
another one at a time, serially.
3. Control Flow Graph (CFG): A CFG is a model that represents the control
flow within a program. It shows the possible execution paths and decisions
that can be made during program execution.
4. Data Flow Analysis: Data flow analysis helps identify how data values
change as a program executes. This is important for optimizing code and
detecting potential issues.
5. Performance Profiling: Profiling tools can be used to collect data on
program execution, such as the time spent in different functions and the
frequency of certain instructions. This data helps identify performance
bottlenecks.
6. Loop Analysis: Programs often contain loops. Analysing loops and their
characteristics can help in optimizing program performance.
Multiprocessor System:
1. Parallelism Models:
- Task-Level Parallelism: In multiprocessor systems, tasks within a
program can be executed concurrently on multiple processors. Task-level
parallelism models help identify opportunities for parallel execution.
- Data-Level Parallelism: Data-level parallelism involves parallelizing
operations on different data elements. SIMD (Single Instruction, Multiple
Data) and MIMD (Multiple Instruction, Multiple Data) models are used for
data-level parallelism.
Requirements Analysis:
Begin with a clear understanding of the system's functional and non-
functional requirements. Define the software's scope and limitations.
Design for Resource Constraints: Consider the limited processing power,
memory, and storage available in embedded systems. Optimize code and
data structures for minimal resource usage.
Modular Design:
Use a modular approach to design software components that can be
developed, tested, and maintained independently. This simplifies
debugging and makes it easier to replace or upgrade specific parts of the
software.
Real-time Analysis: Analyse and specify real-time requirements for the
system. Ensure that the software can meet its deadlines and respond to
events within defined time frames.
Use of Real-time Operating Systems (RTOS):
Employ an RTOS to manage task scheduling, inter-task communication,
and resource allocation. RTOSs provide a structured way to handle real-
time requirements.
Coding Standards:
Define and follow coding standards to ensure consistency in code style and
improve code readability. This is crucial for maintainability.
Testing and Validation:
Rigorous testing is essential. Perform unit testing, integration testing, and
system testing. Validate that the software meets the specified functional and
safety requirements.
Static Analysis: Use static analysis tools to detect potential issues in the
code early in the development process. This can help identify issues related
to code quality, resource usage, and safety.
Dynamic Analysis: Employ dynamic analysis tools for profiling, code
coverage analysis, and memory analysis. This helps in optimizing
performance and identifying memory leaks or corruption.
Continuous Integration: Implement a continuous integration (CI) process to
automate builds and testing. CI systems can ensure that the software
remains functional as changes are made to the codebase.
Version Control: Use a version control system (e.g., Git) to manage changes
to the source code. This enables collaboration, tracks revisions, and
provides a history of the codebase.
Documentation: Maintain comprehensive documentation, including
design documents, source code comments, and user manuals.
Documentation is vital for understanding and maintaining the software.
Safety Standards Compliance: For safety-critical systems (e.g., automotive,
aerospace), adhere to relevant safety standards such as ISO 26262
(automotive) or DO-178C (avionics).
Security Considerations: Implement security measures to protect against
potential vulnerabilities. Embedded systems are increasingly targeted by
security threats, especially in IoT applications.
Code Reviews and Peer Collaboration: Conduct code reviews to ensure
code quality, correctness, and adherence to coding standards. Collaborate
with team members to share knowledge and insights.
Update and Maintenance Planning: Plan for software updates and
maintenance throughout the product's lifecycle. Embedded systems often
have long lifecycles and require ongoing support.
Regulatory Compliance: Ensure that the software development process
complies with industry-specific standards and regulations, particularly in
regulated industries.
Fault Tolerance and Error Handling: Implement fault tolerance mechanisms
and robust error handling to ensure the system can recover from unexpected
failures.
Performance Optimization: Profile and optimize critical parts of the
software for performance, making sure the software can meet its real-time
constraints.
Code Reusability: Encourage code reusability to reduce development effort
and maintain consistent functionality across projects.
HARDWARE/SOFTWARE CO-DESIGN IN EMBEDDED SYSTEM: -
Hardware/software co-design in embedded systems is a collaborative
approach to developing both the hardware and software components of a
system in parallel, with the goal of optimizing system performance, power
efficiency, and cost. It acknowledges that the hardware and software are
interdependent and aims to find the best trade-offs between them. Here are
the key aspects and benefits of hardware/software co-design in embedded
systems:
1. Simultaneous Design: Hardware and software development occurs
concurrently rather than sequentially. This means that the two teams or
aspects of development work closely together from the project's inception.
2. System Optimization:
Performance: Co-design allows for fine-tuning the hardware and software
to maximize system performance. Hardware accelerators can offload
specific tasks, allowing the software to focus on other critical functions.
Power Efficiency: Co-design can help minimize power consumption by
selecting energy-efficient hardware components and optimizing software
algorithms.
3. Trade-offs: Hardware vs. Software: Co-design helps determine which
tasks are better suited for hardware acceleration and which are more
efficiently handled in software. This includes decisions like whether to use
a hardware coprocessor or implement a particular function in software.
Flexibility vs. Performance: Co-design balances the need for system
flexibility with the goal of achieving high performance. Decisions on where
to introduce reconfigurability or programmability are crucial.
4. System-level Perspective: Co-design takes a holistic view of the system,
considering interactions between hardware and software components. It's
not just about optimizing one aspect but achieving an overall system-level
optimization.
5. Rapid Prototyping: Prototyping hardware and software simultaneously
allows for early testing and validation of the system's functionality and
performance. This iterative approach can lead to quicker development
cycles.
6. Reusability: Co-design promotes the creation of modular and reusable
components, both in hardware and software. This reusability can save time
and resources in future projects.
7. Design Space Exploration: Co-design enables the exploration of
different design alternatives and trade-offs, which is especially valuable
when working with constrained resources.
8. Communication and Collaboration: Effective communication and
collaboration between hardware and software teams are essential in co-
design. Teams must work together to define interfaces, share requirements,
and resolve issues.
9. Domain-specific Optimization: In some embedded systems, domain-
specific hardware accelerators are designed to improve performance. Co-
design allows for their seamless integration into the system.
10. Mixed-criticality Systems: - In safety-critical systems,
hardware/software co-design can be used to ensure that high-priority,
safety-critical tasks are handled by dedicated hardware while non-safety-
critical tasks are managed by software.
11. Cost Reduction: Co-design can lead to cost savings by minimizing the
need for overpowered hardware components or by reducing the time
required for software optimization.
12. Real-time Systems: For real-time embedded systems, co-design is
critical for meeting strict timing constraints and ensuring that tasks are
appropriately allocated between hardware and software.
13. Prototyping Tools: Use of tools like virtual prototyping, field-
programmable gate arrays (FPGAs), and simulation environments to
facilitate hardware/software co-design.
Hardware/software co-design is particularly relevant in applications such
as IoT devices, automotive systems, consumer electronics, and any
embedded systems where a balance between hardware and software is
critical for success. It requires a multidisciplinary team with expertise in
both hardware and software development and an integrated approach to
design and development.