0% found this document useful (0 votes)
18 views31 pages

Embedded System Note

Embedded systems are structured in layers including hardware, firmware, operating system, middleware, application, and user interface layers, each serving specific functions. Embedded software is designed for specific hardware, optimizing performance while managing constraints like memory and power. The document also discusses the architecture of the 8051 microcontroller, memory organization, processor characteristics, ARM architecture, and communication methods, highlighting the differences between serial and parallel communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views31 pages

Embedded System Note

Embedded systems are structured in layers including hardware, firmware, operating system, middleware, application, and user interface layers, each serving specific functions. Embedded software is designed for specific hardware, optimizing performance while managing constraints like memory and power. The document also discusses the architecture of the 8051 microcontroller, memory organization, processor characteristics, ARM architecture, and communication methods, highlighting the differences between serial and parallel communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Embedded system layers

Embedded system design typically consists of several layers, which can vary depending on the
complexity of the system. However, a common framework includes the following layers:

1. Hardware Layer: This includes the physical components of the system, such as
microcontrollers, sensors, actuators, and communication interfaces.

2. Firmware Layer: This is the low-level software that directly interacts with the hardware. It
includes device drivers and low-level routines necessary for hardware control.

3. Operating System Layer (if applicable): Some embedded systems use real-time operating
systems (RTOS) to manage hardware resources, tasks, and scheduling. This layer is optional
for simpler systems.

4. Middleware Layer: This layer provides services to software applications beyond those
provided by the operating system. It can include communication protocols, data
management, and APIs that facilitate interaction between software components.

5. Application Layer: This is the topmost layer where the actual application logic resides. It
includes the user interface and higher-level functions that the end-user interacts with.

6. User Interface Layer (if applicabl): For systems with a user-facing component, this layer
includes the graphical or textual interface through which users interact with the system.
These layers help in organizing the design process, making it easier to manage complexity, ensure
modularity, and facilitate testing and maintenance. Depending on the system's requirements, some
layers may be omitted or combined.

Embedded software
Embedded system software is a specialized type of software that controls the hardware of a device
or system: [1, 2, 3]

What it is

Embedded software is a type of application or firmware that's designed to control the functions of a
device without compromising its efficiency or purpose. It's created specifically for the device it runs
on, and is tightly integrated with the device's hardware components. [1, 2, 4]

Where it's used

Embedded software is found in many electronic devices, including cars, phones, robots, appliances,
and more. [3]

How it works

Embedded software is optimized for speed, size, and power consumption, and is subject to
constraints like limited memory and CPU usage. It's often programmed using specialized tools to
ensure optimal performance. [3, 4]

How it differs from other software


Unlike general-purpose software, embedded software has fixed hardware requirements and
capabilities. It's not usually controlled by a human interface, but rather by machine interfaces. [2, 5]

Development

Developing embedded software requires a deep understanding of hardware constraints and how
they impact performance. It also requires skills, patience, and attention. [4]

Tools

Some tools used for embedded software development include PyCharm, which provides features like
code completion, error highlighting, and automated code refactoring. [6]

Brief overview of 8051 Architecture and real world


interfacing
### Architecture of 8051 Microcontroller

1. **Central Processing Unit (CPU)**: The heart of the 8051, responsible for executing instructions.

2. **Memory**:

- **Program Memory**: 4KB of ROM, used for storing the program code.

- **Data Memory**: 128 bytes of RAM, which includes 32 bytes of general-purpose registers, 16
bytes of bit-addressable registers, and 80 bytes of general RAM.

3. **Registers**:

- **Accumulator (ACC)**: Used for arithmetic and logical operations.

- **B Register**: Used in conjunction with the ACC for multiplication and division.

- **Program Status Word (PSW)**: Contains status bits that reflect the outcome of CPU
operations.

- **Stack Pointer (SP)**: Points to the stack's top of memory.

- **Data Pointer (DPTR)**: A special 16-bit register for external data memory address.

4. **Ports**:

- **Port 0 to Port 3**: Four 8-bit I/O ports, providing a total of 32 I/O lines.

5. **Timers/Counters**: Two 16-bit timers/counters used for measuring time intervals and event
counting.

6. **Serial Communication**: Integrated UART for serial communication.

7. **Interrupt System**: Supports five interrupt sources with two priority levels.

### Real-World Interfacing

The 8051 microcontroller is versatile and can interface with various real-world devices:
1. **LEDs and LCDs**: Used for visual feedback in projects.

2. **Keyboards and Switches**: Can interface with various input devices, like keypads.

3. **Sensors**: Interfaces with analog and digital sensors for data acquisition.

4. **Motors**: Control stepper motors and DC motors in robotics and automation.

5. **Serial Devices**: Communicate with other devices via serial communication protocols like UART.

6. **Memory Devices**: Connects to external memory modules to expand storage capabilities.

7. **Displays**: Interfaces with seven-segment displays, OLEDs, and graphical displays.

Would you like to dive deeper into any specific interfacing example?

Memory Organization in Embedded Hardware


Memory organization in embedded hardware is structured to ensure efficient storage, retrieval, and
processing of data. It typically involves the following types of memory:

1. Program Memory (ROM/Flash):

o Stores the firmware or program code.

o Non-volatile, meaning it retains data even when power is off.

o Examples include Flash, EEPROM, and PROM.

2. Data Memory (RAM):

o Stores temporary data during program execution.

o Volatile, meaning data is lost when power is removed.

o Includes Static RAM (SRAM) for fast access and Dynamic RAM (DRAM) for higher
capacity.

3. Non-Volatile Data Memory:

o Used to store configuration settings, logs, or infrequently updated data.

o Examples include EEPROM and FRAM.

4. Memory Mapping:

o Embedded systems often use memory-mapped I/O, where peripherals are assigned
specific memory addresses.

o A memory map defines the layout and accessibility of different memory regions
(program, data, peripheral registers, etc.).

5. Cache Memory:

o Found in advanced embedded processors.


o Stores frequently accessed data to speed up processing.

o Includes instruction cache, data cache, or both.

6. Stack and Heap:

o Stack: Stores function call data, return addresses, and local variables.

o Heap: Allocates memory dynamically during runtime.

Processor in Embedded Hardware


The processor in embedded hardware, often referred to as the microcontroller unit (MCU) or
microprocessor unit (MPU), is the core component responsible for executing instructions. Key
characteristics include:

1. Types of Processors:

o General-purpose processors (GPPs): Used in versatile applications.

o Application-specific processors (ASPs): Designed for specific tasks (e.g., DSPs).

o Microcontrollers (MCUs): Integrated processors with onboard memory and


peripherals.

2. Architectural Features:

o Harvard vs. Von Neumann Architecture:

 Harvard: Separate memory buses for instructions and data, enabling


simultaneous access.

 Von Neumann: Shared bus for instructions and data, simpler but slower.

o RISC vs. CISC:

 RISC (Reduced Instruction Set Computer): Simple instructions, high


performance, and energy efficiency.

 CISC (Complex Instruction Set Computer): Rich instruction set, optimized for
complex tasks.

3. Clock Speed:

o Determines the speed of instruction execution.

o Typically lower than desktop processors to conserve power.

4. Power Efficiency:

o Embedded processors prioritize low power consumption, critical for battery-powered


devices.

5. Peripheral Interfaces:
o Embedded processors often include integrated interfaces like GPIO, I2C, SPI, UART,
ADC, and DAC.

6. Interrupt Handling:

o Interrupt-driven operation allows immediate response to events, crucial for real-time


systems.

7. Real-Time Capabilities:

o Many embedded systems use real-time processors to meet strict timing constraints.

Conclusion

The combination of efficient memory organization and tailored processor designs enables embedded
hardware to meet the demands of specific applications, balancing performance, power consumption,
and cost.

ARM architecture

It is a family of reduced instruction set computing (RISC) architectures for computer processors,
configured for various environments. ARM processors are widely used in mobile devices, embedded
systems, and increasingly in other areas due to their power efficiency and performance. Here are the
key aspects of ARM architecture:

### **Key Features:**

1. **RISC Architecture:** ARM uses a reduced instruction set computing approach, meaning it has a
small, highly optimized set of instructions, which simplifies the processor design and improves
performance.

2. **Power Efficiency:** ARM processors are known for their low power consumption, making them
ideal for battery-powered devices like smartphones and tablets.

3. **Versatility:** ARM processors are used in a wide range of devices, from small embedded
systems to powerful servers.

4. **Performance:** Despite their power efficiency, ARM processors can deliver high performance,
especially with modern designs that incorporate features like multiple cores and advanced caching.

5. **Scalability:** ARM architecture is scalable, allowing it to be used in a variety of applications


from simple microcontrollers to complex server processors.

### **Instruction Set:**

- **32-bit and 64-bit:** ARM architecture supports both 32-bit (ARMv7) and 64-bit (ARMv8 and
later) instruction sets.
- **Thumb and Thumb-2:** ARM processors include Thumb and Thumb-2 instruction sets, which
provide compressed 16-bit instructions for improved code density and efficiency.

### **Applications:**

- **Mobile Devices:** Smartphones, tablets, and wearables.

- **Embedded Systems:** IoT devices, automotive systems, and industrial control.

- **Consumer Electronics:** Smart TVs, gaming consoles, and set-top boxes.

- **Servers and Networking:** High-performance ARM processors are used in data centers and
networking equipment.

### **Advantages:**

- **Low Power Consumption:** ARM's power efficiency extends battery life in portable devices.

- **High Performance:** Efficient processing capabilities make it suitable for a wide range of
applications.

- **Cost-Effectiveness:** ARM's simple design can reduce manufacturing costs.

### **Popular ARM Processors:**

- **Cortex-M Series:** Designed for microcontrollers and low-power applications.

- **Cortex-A Series:** Focuses on high performance for mobile and consumer devices.

- **Cortex-R Series:** Real-time applications requiring high reliability.

- **Neoverse:** Designed for infrastructure and cloud applications.

ARM architecture's combination of performance, power efficiency, and versatility has made it a
dominant player in the processor market, especially for mobile and embedded applications.

In embedded systems, serial and parallel communication ports are used to transfer data between
devices. These ports differ in how they handle data transmission.

Thumb
The Thumb instruction set is a subset of the 32-bit ARM instruction set that's used in ARM
processors:

Size

Thumb instructions are 16 bits long, which is half the length of ARM instructions. This results in
smaller code size and lower storage memory costs. [1, 3]

Performance
Thumb code is typically 65% the size of ARM code, but can perform at 160% of ARM code's
performance when running from a 16-bit memory system. [1]

Interoperability

Thumb instructions operate with the standard ARM register configuration, allowing for seamless
interoperability between ARM and Thumb states. [1]

Decompression

Thumb instructions are decompressed to 32-bit ARM instructions in real time, without performance
loss.

Limitations
Thumb instructions have some limitations, such as only accessing the bottom eight registers and
lacking conditional execution.

Thumb-2 technology

ARMv6T2 introduced Thumb-2 technology, which allows for 32-bit Thumb instructions. This allows
Thumb code to achieve similar performance to ARM code, while maintaining better code density. [2]

ThumbEE instruction set

ARMv7 defines the Thumb Execution Environment (ThumbEE) instruction set, which is based on
Thumb but with some changes for dynamically generated code. [4]

Thumb-2

Thumb-2 is an extension of the 16-bit Thumb instruction set that adds 32-bit instructions to the ARM
architecture:

 Functionality

Thumb-2 combines the code density of earlier Thumb versions with the performance of the ARM
instruction set.

 Instruction set

Thumb-2 instructions can be a mix of 16-bit and 32-bit instructions, and every instruction must start
on an even address.

 Conditional execution

Most 32-bit Thumb instructions are unconditional, but Thumb-2 introduces the IT instruction, which
is a logical if-then-else function that can make following instructions conditional.

 Access

Thumb-2 instructions are accessible when the processor is in Thumb state, which is when the T bit in
the CPSR is 1 and the J bit is 0.
 Performance

A processor can switch between executing Thumb and ARM instructions, especially for performance-
critical segments like handling interrupts

Here are some other details about Thumb-2:

 The instruction length and functionality is determined by the first halfword (hw1).

 The second halfword (hw2) of the instruction is fetched from the instruction address plus
two if the instruction is decoded as being 32-bits long.

 The 32-bit ARM Thumb-2 instructions are added in the space occupied by the Thumb BL and
BLX instructions.

Serial Communication Port


In serial communication, data is transmitted one bit at a time over a single data line. This approach is
widely used in embedded systems for long-distance communication and when minimizing the
number of physical connections is essential.

Characteristics:

 Data Transmission: One bit at a time (sequential).

 Wiring: Requires fewer wires (typically 2 or 3: TX, RX, and Ground).

 Speed: Generally slower than parallel for short distances but sufficient for most applications.

 Distance: Effective over long distances.

 Synchronization: Data can be synchronized using clock signals (synchronous) or without


clock signals (asynchronous).

Common Protocols and Interfaces:

1. UART (Universal Asynchronous Receiver-Transmitter):

o Asynchronous communication (no clock signal).

o Commonly used in serial ports of microcontrollers.

o Example: RS232, RS485.

2. SPI (Serial Peripheral Interface):

o Synchronous communication (uses a clock signal).

o Faster and supports full-duplex communication.

o Commonly used for short-distance communication with peripherals like sensors and
displays.

3. I²C (Inter-Integrated Circuit):

o Synchronous and multi-master capable.


o Uses two lines: SDA (data) and SCL (clock).

o Suitable for connecting multiple devices on the same bus.

4. CAN (Controller Area Network):

o Used in automotive and industrial applications.

o Designed for robust communication in noisy environments.

Advantages:

 Requires fewer wires.

 Simpler connections.

 Reliable over long distances.

Disadvantages:

 Slower data transfer rates for large amounts of data.

 May require more complex protocols for error checking.

Parallel Communication Port


In parallel communication, multiple bits are transmitted simultaneously over multiple data lines.
This method is ideal for short-distance, high-speed data transfer.

Characteristics:

 Data Transmission: Multiple bits at a time (simultaneous).

 Wiring: Requires more wires (one for each data bit, plus control and ground lines).

 Speed: Faster than serial communication for short distances.

 Distance: Limited due to signal degradation over long distances.

 Synchronization: Typically requires a clock signal for coordination.

Common Uses:

1. Parallel Data Buses:

o Used for connecting microcontrollers to peripherals like memory, LCDs, or sensors.

o Example: Address and data buses in microprocessors.

2. GPIO (General-Purpose Input/Output):

o Can be configured for parallel data transfer in some embedded systems.

3. Parallel Peripheral Interfaces:

o Older standards like the Centronics interface for printers.

Advantages:
 High-speed data transfer.

 Suitable for transferring large volumes of data.

Disadvantages:

 Requires more physical connections, increasing PCB complexity.

 Signal integrity issues over long distances.

Comparison of Serial and Parallel Communication


Feature Serial Communication Parallel Communication

Data Transfer One bit at a time Multiple bits at a time

Speed Slower for short distances Faster for short distances

Wiring Fewer wires More wires

Distance Suitable for long distances Limited to short distances

Complexity Simpler hardware More complex hardware

Applications UART, I²C, SPI, CAN Memory buses, GPIO, LCD

Conclusion

Both serial and parallel communication ports play vital roles in embedded systems, and the choice
between them depends on the specific application requirements, such as speed, distance, and
hardware complexity.

CAN
The Controller Area Network (CAN) protocol is a communication protocol that was developed for use
in the automotive industry, but has also been used in other industries such as industrial automation
and medical equipment. It is a serial communication protocol that uses a multi-master, distributed
control system. This means that any device on the network, called a node, can initiate
communication and all other nodes on the network can participate in the communication. The
protocol provides a way for devices to share information and synchronize their actions without the
need for a central controller. The protocol uses a collision detection and arbitration method to
prevent multiple nodes from transmitting at the same time and ensure that only one node can
transmit at a time.

Why CAN?
The CAN protocol was developed for use in the automotive industry to address several challenges
that arose as cars became more complex and incorporated more electronic systems. Some of the key
reasons for why the CAN protocol was developed include −

 High reliability − The CAN protocol is designed to be robust and fault-tolerant, making it
suitable for use in critical systems such as the engine control and braking systems in a car.

 Low cost − The CAN protocol uses a simple and efficient signaling method that allows for
low-cost implementation, which is particularly important in the automotive industry where
costs are a major concern.

 Low weight and minimal wiring − The CAN protocol uses a two-wire bus, which reduces the
amount of wiring needed in a car and makes the vehicle lighter, which can lead to improved
fuel efficiency.

 Scalability − The CAN protocol is designed to support a large number of devices on a


network, making it easy to add new devices or remove existing ones as needed.

 Multi-master capability − The ability of the any device (node) to initiate communication in
the network, this allows different systems to communicate and act upon their requirement
and also enables distributed control which is a major feature of this protocol.

Applications of CAN protocol

The Controller Area Network (CAN) protocol is widely used in a variety of applications, including −

 Automotive − The CAN protocol was originally developed for use in the automotive industry
and is used in a wide variety of systems in modern cars, including engine control,
transmission control, anti-lock brakes, and body electronics.

 Industrial automation − The CAN protocol is used in industrial automation systems to allow
devices to communicate and coordinate their actions, such as controlling motors, sensors,
and other equipment.
 Medical equipment − The CAN protocol is used in medical equipment to control various
functions and to transmit data between devices. For example, patient monitoring systems
use the protocol to transmit patient vital signs data between devices

 Avionics − The protocol is used in avionics to control and monitor various systems such as
engine, navigation, and flight control systems.

 Building automation − The protocol is used in building automation systems to control and
monitor various systems such as heating, ventilation, air conditioning (HVAC), lighting, and
security systems.

 Robotics − The protocol is used in Robotics to control and monitor various systems such as
motors, sensors, and other equipment, thus allowing the robots to communicate and
coordinate their actions.

I2C
I2C (Inter-Integrated Circuit) is a serial communication protocol that allows devices to
communicate in embedded systems. It's commonly used for short-distance communication
between microcontrollers and peripheral devices. [1, 2]

How it works [1, 3]

 I2C uses two wires, SDA (Serial Data) and SCL (Serial Clock), to send and receive data. Data
on the SDA line can change only when the clock line (SCL) is low. This prevents errors during
data transfer. The lines are "open-drain", meaning a resistor is needed to pull them up when
not active.

 Data is sent as follows:

Start state- 1 bit

Slave address- 8 bit

Acknowledgement-1bit

 The master device provides the clock signal, which determines the data transfer rate. [1]

 I2C is a bidirectional bus, meaning the master can read from and write to the slave. [1]

 I2C has a built-in arbitration mechanism to resolve conflicts if multiple devices try to
communicate at the same time. [4]

Why it's used [1, 5]

 I2C is a simple, low-cost solution for communication between devices.

 It's used in many applications, including consumer electronics, automotive, aerospace, and
industrial equipment.

Related protocols [6]


 SPI (Serial Peripheral Interface): Another serial communication protocol used in embedded
systems. It's often used for high-speed data exchanges.

Digital camera
A digital camera is a fascinating example of an embedded system. Here's a brief overview of a case
study on digital cameras in embedded systems:

### Key Components

1. **Image Sensor**: The heart of the digital camera, typically a CCD (Charge-Coupled Device) or
CMOS (Complementary Metal-Oxide-Semiconductor) sensor, captures light and converts it into
electrical signals.
2. **Processor**: A microcontroller or digital signal processor (DSP) handles image processing tasks
such as noise reduction, color correction, and compression.
3. **Memory**: Stores captured images and firmware. This can include both volatile memory (RAM)
and non-volatile memory (flash).

4. **Interface**: Connects the camera to other devices, such as USB, HDMI, or wireless connections
for transferring images.

5. **Display**: LCD screen for viewing images and navigating menus.

### Design Challenges

- **Optimizing Design Metrics**: Balancing cost, size, performance, power consumption, and
flexibility.
- **Real-Time Processing**: Ensuring timely processing of images to provide a smooth user
experience.

- **Power Efficiency**: Designing for low power consumption to extend battery life.

### Implementation

- **Hardware Design**: Integrating various components on a single chip or board.

- **Software Design**: Developing firmware for controlling the hardware and providing user
interface functionalities.

### Applications

- **Consumer Electronics**: Digital cameras in smartphones, tablets, and standalone cameras.

- **Industrial and Medical Imaging**: High-resolution cameras for inspection and diagnostic
purposes.

Would you like more detailed information on any specific aspect of this case study?
Preprocessor in C
Preprocessors are programs that process the source code before compilation. Several steps are
involved between writing a program and executing a program in C. Let us have a look at these steps
before we actually start learning about Preprocessors.
You can see the intermediate steps in the above diagram. The source code written by programmers is
first stored in a file, let the name be “program.c“. This file is then processed by preprocessors and an
expanded source code file is generated named “program.i”. This expanded file is compiled by the
compiler and an object code file is generated named “program.obj”. Finally, the linker links this
object code file to the object code of the library functions to generate the executable file
“program.exe”.

Preprocessor Directives in C
Preprocessor programs provide preprocessor directives that tell the compiler to preprocess the
source code before compiling. All of these preprocessor directives begin with a ‘#’ (hash) symbol. The
‘#’ symbol indicates that whatever statement starts with a ‘#’ will go to the preprocessor program to
get executed. We can place these preprocessor directives anywhere in our program.

What is Embedded C?
Embedded C is a programming language that is used in the development of Embedded Systems.
Embedded Systems are specialized systems designed to perform very specific functions or tasks.
Embedded System is the combination of hardware and software, and the software is generally
known as firmware which is embedded into the system hardware. Embedded C is used to program a
wide range of microcontrollers and microprocessors. Embedded C requires less number of resources
to execute in comparison with high-level languages such as assembly programming language.

Embedded C has some additional data types and keywords. There are some special datatypes in
Embedded C like sbit, sfr which are used for addressing special function registers in memory.
Embedded C allows us to work with hardware devices like sensors, and input-output devices. There
are various Embedded C compilers to compile the embedded C program such as Keil Compiler, SPJ
Compiler, Embedded GNU C Compiler, etc. Embedded Systems can be classified into small-scale,
medium-scale, and sophisticated embedded systems. The devices like air conditioners, printers, and
mobile phones that we use in our daily lives are programmed by embedded C.

Key Characteristics of Embedded C


Efficiency: In Embedded C we can create an efficient code to optimize the limited resources available
in embedded systems. It aims to minimize memory usage and maximize performance.

Direct Hardware Interaction: Embedded C allows programmers to interact directly with hardware
components, such as microcontrollers, sensors, actuators, and other peripherals. This direct
interaction facilitates precise control over the hardware, critical in embedded applications.

Low-level Programming: Embedded C involves low-level programming, which deals with hardware-
specific details like memory addresses, I/O ports, and register manipulation. This level of control is
essential for efficiently managing hardware resources.

Real-time Operations: Embedded systems often operate in real-time environments, requiring precise
timing and response to events. Embedded C allows programmers to handle real-time tasks efficiently.

Structure of Embedded C Program

 Comments: Comments are readable text written to help user understand the code easily.
They are ignored by compiler and do not take up any memory in the final code. There are
two types of comments, Single line comments and Multiline comments.

 Preprocessor Directive: In Embedded C Preprocessor Directives are represented using


#include or #define. Preprocessor Directives are used to indicate a header file specific to a
microprocessor or microcontroller which contains all the functions, SFR's and the bits in
those SFR's. reg51 header file is used in case of 8051 microcontroller.

 Global Variables: Global variables as the name suggests are global to program that is they
can be accessed anywhere in the program. Global variables are static variables and are
placed in RAM memory locations.

 Local Variables: Local variables in contrast to global variables are confined to their respective
functions. Normally these variables are placed in stack or registers. It is only valid within the
function in which it is declared.

 Function: Function is a group of statements that together performs a task. A function


declaration tells the compiler about the name, return type and parameter of the function. A
function definition provides actual body of the function
 Main Function: Every Embedded c program has one main function and may contain one or
more functions in the main functions. The program execution starts from the main function,
and it is a core of every execution. If more than one main function is written in the code,
then compiler will confuse from where to start the program execution.

What is Embedded C++


Embedded C++ refers to the use of C++ programming language in embedded systems, which are
specialized computing systems designed to perform specific tasks, often with real-time
constraints. Embedded C++ leverages the features of C++ while tailoring its usage to fit the
resource-constrained environment of embedded systems, such as limited memory, low
processing power, and strict timing requirements.

Here’s a breakdown of the concept:

Key Features of Embedded C++:

1. Subset of Standard C++:

o Embedded C++ may restrict certain features of standard C++ to ensure compatibility
with embedded systems. For example:

 Avoiding dynamic memory allocation (new/delete) to prevent memory


fragmentation.

 Limited use of the Standard Template Library (STL) to reduce memory usage.

 Minimal or no exception handling due to runtime overhead.

2. Object-Oriented Programming (OOP):


o Embedded C++ allows developers to use OOP principles such as classes, inheritance,
and polymorphism, which improve code modularity, reusability, and maintainability.

3. Low-Level Hardware Interaction:

o It supports direct interaction with hardware, similar to C, through pointers and bit-
level operations, making it suitable for programming embedded devices.

4. Performance Optimization:

o Embedded C++ focuses on efficiency. Developers often write performance-critical


sections of the code in a "C-like" subset of C++ to minimize overhead.

5. Portability and Scalability:

o Using C++ enables better scalability across different embedded platforms due to its
abstraction capabilities while maintaining performance.

Why Use Embedded C++?

 Abstraction and Code Reusability: The OOP features make it easier to manage complex
systems and reuse code.

 Flexibility: It balances low-level control (like C) with higher-level programming constructs.

 Scalability: Suitable for both small microcontroller projects and larger embedded systems.

 Industry Adoption: Many embedded development environments support C++ compilers and
tools.

Challenges of Embedded C++:


1. Resource Constraints:

o Embedded systems often have limited memory and processing power, making some
C++ features impractical.

2. Complexity:

o C++ is more complex than C, potentially increasing the learning curve and the chance
of introducing bugs.

3. Overhead:

o Features like RTTI (Run-Time Type Information) and virtual functions can add
runtime overhead, which may not be acceptable in real-time systems.

Examples of Embedded C++ in Practice:

1. Microcontroller Programming:

o Writing drivers, handling interrupts, and managing peripherals in C++.

2. Real-Time Systems:

o Developing real-time applications using frameworks like FreeRTOS or bare-metal


programming.

3. IoT Devices:

o Writing software for devices with networking and sensor integration.

What is a Real-Time Operating System (RTOS)?


A real-time operating system (RTOS) is a special kind of operating system designed to handle
tasks that need to be completed quickly and on time. Unlike general-purpose operating
systems (GPOS), which are good at multitasking and user interaction, RTOS focuses on doing
things in real time.

idea of real-time computing has been around for many years. This early system allowed
multiple processes to run at the same time, each within strict time limits.

Over the years, RTOS has improved with new technology and the need for reliable real-time
performance. These systems are now more powerful, efficient, and full of features, and they
are used in many industries, including aerospace, defense, medical science, multimedia, and
more.

Types of Real-Time Operating System

The real-time operating systems can be of 3 types –


Hard Real-Time Operating System

These operating systems guarantee that critical tasks are completed within a range of
time. For example, a robot is hired to weld a car body. If the robot welds too early or too
late, the car cannot be sold, so it is a hard real-time system that requires complete car
welding by the robot hardly on time., scientific experiments, medical imaging systems,
industrial control systems, weapon systems, robots, air traffic control systems, etc.

Soft Real-Time operating system:

Soft RTOS accepts a few delays via the means of the Operating system. In this kind of RTOS,
there may be a closing date assigned for a particular job, but a delay for a small amount of
time is acceptable. So, cut off dates are treated softly via means of this kind of RTOS.
For Example This type of system is used in Online Transaction systems and Livestock price
quotation Systems.

Firm Real-Time operating system:

In Firm RTOS additionally want to observe the deadlines. However, lacking a closing date
might not have a massive effect, however may want to purposely undesired effects, like a
massive discount within the fine of a product.

Purpose of RTOS :

Unlike general-purpose operating systems (GPOS) like Windows or Linux, which are good at
multitasking and handling various applications, a real-time operating system (RTOS) is
designed to manage time-sensitive tasks precisely.

The main goal of an RTOS is to perform critical tasks on time. It ensures that certain
processes are finished within strict deadlines, making it perfect for situations where timing is
very important. It is also good at handling multiple tasks at once.

An RTOS provides real-time control over hardware resources, like random access
memory (RAM), by ensuring predictable and reliable behavior. It uses system resources
efficiently while maintaining high reliability and responsiveness. By managing multiple tasks
effectively, an RTOS ensures smooth operation even when the system is under heavy use or
changing conditions.

Uses of RTOS

 Defense systems like RADAR .

 Air traffic control system.

 Networked multimedia systems.

 Medical devices like pacemakers.

 Stock trading applications.

Basic Model of a Real-time System


Real-time System is a system that is used for performing some specific tasks. These tasks are related
with time constraints and need to be completed in that time interval.
Basic Model of a Real-time System: The basic model of a real-time system presents the overview of
all the components involved in a real-time system. Real-time system includes various hardware and
software embedded in a such a way that the specific tasks can be performed in the time constraints
allowed. The accuracy and correctness involved in real-time system makes the model complex. There
are various models of real-time system which are more complex and are hard to understand. Here
we will discuss a basic model of real-time system which has some commonly used terms and
hardware. Following diagram represents a basic model of Real-time System:

Sensor: Sensor is used for the conversion of some physical events or characteristics into the
electrical signals. These are hardware devices that takes the input from environment and
gives to the system by converting it. For example, a thermometer takes the temperature as
physical characteristic and then converts it into electrical signals for the system.

Actuator: Actuator is the reverse device of sensor. Where sensor converts the physical
events into electrical signals, actuator does the reverse. It converts the electrical signals into
the physical events or characteristics. It takes the input from the output interface of the
system. The output from the actuator may be in any form of physical action. Some of the
commonly used actuator are motors and heaters.
Signal Conditioning Unit: When the sensor converts the physical actions into electrical
signals, then computer can’t used them directly. Hence, after the conversion of physical
actions into electrical signals, there is need of conditioning. Similarly while giving the output
when electrical signals are sent to the actuator, then also conditioning is required. Therefore,
Signal conditioning is of two types:

 Input Conditioning Unit: It is used for conditioning the electrical signals coming from sensor.

 Output Conditioning Unit: It is used for conditioning the electrical signals coming from the
system.

Interface Unit: Interface units are basically used for the conversion of digital to analog and vice-
versa. Signals coming from the input conditioning unit are analog and the system does the
operations on digital signals only, then the interface unit is used to change the analog signals to
digital signals. Similarly, while transmitting the signals to output conditioning unit the interface of
signals are changed i.e. from digital to analog. On this basis, Interface unit is also of two types:

 Input Interface: It is used for conversion of analog signals to digital.

 Output Interface: It is used for conversion of digital signals to analog.

What is a Watchdog Timer?


At its core, a watchdog timer is a hardware or software component that is designed to detect and
recover from system malfunctions. It works by monitoring the system and triggering a reset if a
failure is detected. The goal is to ensure that the system always operates within a certain set of
parameters and doesn’t drift off course due to unexpected events or bugs.

How Does a Watchdog Timer Work?


A watchdog timer works by periodically monitoring the system and resetting it if a certain
condition is met. The exact implementation can vary depending on the specific system and
application, but here’s a high-level overview of how it typically works:

1. The watchdog timer is initialized with a timeout value. This value determines how long the
watchdog timer will wait before triggering a reset.

2. The system or application being monitored regularly resets the watchdog timer. This can be
done in a variety of ways, such as writing to a specific memory location or sending a signal.

3. If the watchdog timer is not reset within the specified timeout period, it assumes that a
failure has occurred and triggers a reset of the system or application.

4. The reset caused by the watchdog timer will typically be a “hard” reset, which means that
the system or application will be completely restarted from scratch.

Why are Watchdog Timers Important?

So why are watchdog timers so important for reliable system operation? There are a few key
reasons:

1. Automatic recovery: By using a watchdog timer, it’s possible to automatically recover from
software or hardware failures without requiring human intervention. This can help to
improve the overall reliability and availability of a system or application.

2. Preventative maintenance: By regularly resetting the watchdog timer, the system can
proactively identify and correct potential issues before they become major problems.

3. Real-time monitoring: A watchdog timer can provide real-time monitoring of a system or


application, giving engineers insight into its performance and behavior.
4. Compliance: For some industries, such as aerospace and defense, watchdog timers are a
mandatory requirement to ensure that systems operate within certain safety-critical
parameters.

Types of Watchdog Timers:


There are two main types of watchdog timers: hardware and software.

Hardware watchdog timers are typically built into a microcontroller or other hardware
device. They use a dedicated hardware counter to track the timeout period and trigger a
reset when necessary.

Software watchdog timers, on the other hand, are implemented in software using a timer
interrupt. They use the system clock to track the timeout period and trigger a reset when
necessary.

Watchdog timers are commonly used in safety-critical applications such as aerospace,


automotive, and medical devices. They are also used in industrial control systems,
embedded systems, and other applications where system uptime and reliability are critical.
In safety-critical applications, watchdog timers are often required by industry
standards and regulations to ensure that systems operate within certain safety-critical
parameters. For example, in the aerospace industry, watchdog timers are used to
ensure that flight control systems operate safely and reliably.

comparing Timer and Watchdog Timer


The primary distinction between a timer and a watchdog timer lies in their
application.

A timer is a broad concept that is used in a wide variety of applications, such as


scheduling, timekeeping, counting, and the generation of waveforms.

It plays a key role in maintaining the flow of operations and can be utilised in a wide
array of applications.

On the other hand, a watchdog timer is specifically designed to enhance system


reliability by detecting and resolving system faults. Its primary application is in error
detection and system recovery.

In essence, while all watchdog timers are timers, not all timers are watchdog timers.
This is because the watchdog timer serves a specialised function within the broader
category of timers.

ADC: Analog-to-Digital Converter


ADC stands for analog-to-digital converter. It (ADC, A/D, or A-to-D Converter) is a
device primarily used to convert the signal; it first takes an Analog signal and then
turns it into a digital format. AD converters are used for different purposes, and they
are used in a variety of applications, such as digital music, radio, and digital
photography. It is also used for digital signal processing.

The concept that is used in ADC is quite simple. The working of ADC is very
straightforward; it takes an Analog signal and then converts it into digital format. It
transforms an Analog signal of various forms, such as sound or electricity, into a
digital representation. These ADC devices receive and store data using billions of
small binary digits.
Working:
Analog to digital converter is considered a beneficial component when dealing with
digital systems because it communicates with real-time signals. These digital systems
must interpret real-world/time signals to correctly give crucial information. For
instance, IoT develops fast applications and devices in daily life with the help of ADCs.
We will now go into the theory and operation of ADCs.

In the real world, Analog signals are mainly those signals that have a chaining
sequence with a constant value (though there are certain cases in which it can be
limited). These types of signals are acquired from various sources; they can come as
sound, light, temperature and motion. Digital signals are mainly represented with the
help of a sequence of discrete values. The way that discrete values are used to
describe digital signals depends on the time series or sampling rate at which the
signals are divided into sequences (more on later).

The simplest way to explain this is through an easy diagram. An excellent


representation of both Analog and digital signals may be seen in the following
image, where the red line represents the Analog input signals while the green line
represents the digital output signals.

Importance of Analog to Digital Conversion


 The main role of ADC in modern technology development process is the transition of
voice communication systems from outdated analogue signal processing to the more
advanced voice over IP, or VoIP, systems of today is largely due to the contribution.
 The teletypewriters and other computer input devices needed to be connected to a
modem which was connected to a mainframe or other front end computer system to
communicate with the required computer systems. In contrast to the ultrahigh-speed
networks of today, modem transmission speeds were modest to process.

 The systems for smaller office applications and the digital private branch exchange,
or PBX, were developed by using ADC technology as the foundation to process
properly.

EEPROM
EEPROM stands for Electrically Erasable Programmable Read-Only Memory. EEPROM is
a type of non-volatile primary memory and modified version of EPROM (Erasable
Programmable Read-Only Memory) which uses electrical signals to erase and program the
contents rather than UV signals which was used previously in EPROM. It is used as a chip in
computers to store the digital data.

There are two types of EEPROM:

 Serial EEPROM

 Parallel EEPROM

1. Serial EEPROM

In comparison to parallel EEPROM chips, serial EEPROM chips are denser since they may fit
into a compact eight-pin package. Moreover, serial chips are less costly. Data is sent serially
and moves slowly, which is a downside. Their operations are also more complicated.

2. EEPROM in parallel

Both flash memory and EPROM devices can use the parallel EEPROM chip. Compared to the
serial EEPROM method, it has a quicker and more reliable data transfer mechanism. Its size,
density, and price are all higher due to the higher pin count. Because of these factors, flash
memory or serial EEPROM is more commonly utilised than parallel EEPROM.

Characteristics
 Less time consuming: EEPROM takes 5-10 milliseconds to erase the content
electronically unlike, EPROM takes minutes to erase the same content using UV
signals.
 Programmable and erasable content: It can reprogrammed n number of times and
that life cycle has to be defined by the manufacture and it can be maximum of 1
million life cycles in modern EEPROMs.

 No detaching of chip: To reprogram or erase the content, there is no need to take


the chip out of the computer.

Advantages
 Fast erasing of data as it uses electrical signals and can erase all contents or can erase
by particular byte.

 Data stored is non-volatile and retains even if the power is off.

 Easy to reprogram without taking it out from computer and does not require any
additional equipments for reprogramming.

Disadvantages
 Data retention problem as insulator used is not a perfect insulator and manufacture
provides data retention upto 10 years.

 It requires different voltages for reading, writing and erasing the content.

Processor Architecture
1. Features

- **Instruction Set Architecture (ISA)**: Defines the set of commands that a processor can
execute.

- **Pipeline**: Enhances the processing speed by allowing multiple instructions to overlap


during execution.

- **Clock Speed**: Indicates the number of cycles a processor executes per second,
impacting performance.

- **Cores**: Multiple cores can process parallel instructions, improving multitasking.

- **Cache**: Small, fast memory located close to the CPU to speed up access to frequently
used data.

- **Bus Architecture**: Determines data transfer rates between the processor and other
components.

2. Memory Organization
- **Registers**: Fast, small storage locations within the CPU used for immediate data
manipulation.

- **Cache Memory**: Hierarchical storage closer to the CPU to reduce latency (L1, L2, L3
caches).

- **RAM (Random Access Memory)**: Volatile memory used for current operations and data
storage.

- **ROM (Read-Only Memory)**: Non-volatile memory storing essential instructions for


booting the system.

- **EEPROM (Electrically Erasable Programmable Read-Only Memory)**: Non-volatile


memory that can be electrically erased and reprogrammed.

3. On-Chip Peripherals

-**Timers**: Keep track of time for various processes and are essential for system tasks
scheduling.

-**Interrupt Controllers**: Manage interrupt signals for prioritizing and handling different
tasks.

-**Communication Interfaces**: Such as UART, SPI, and I2C to facilitate data exchange
between devices.

- **ADC (Analog-to-Digital Converter)**: Converts analog signals into digital data for
processing.

- **DAC (Digital-to-Analog Converter)**: Converts digital data back to analog signals for
output.

### 4. Watchdog Timer

- **Purpose**: It ensures the system recovers by resetting the processor if a malfunction is


detected.

- **Function**: If the system fails to reset the timer regularly, it indicates a software fault, and
the timer triggers a system reset to recover.

### 5. ADC (Analog-to-Digital Converter)

- **Functionality**: It converts analog signals (like temperature, pressure, or sound) into


digital values that can be processed by the CPU.

- **Resolution**: Determines how fine the digital representation is (common resolutions are
8-bit, 10-bit, 12-bit, etc.).
- **Speed**: Defines the rate at which analog signals are sampled and converted.

### 6. Data EEPROM (Electrically Erasable Programmable Read-Only Memory)

- **Non-volatile**: It retains data even when the power is off.

- **Reprogrammable**: Can be written, erased, and reprogrammed multiple times.

- **Usage**: Ideal for storing configuration settings, parameters, and small amounts of data
that need to be preserved between power cycles.

The **Microchip PIC16 family** is a popular series of 8-bit microcontrollers designed by


Microchip Technology. These microcontrollers are widely used in various applications due to
their versatility, low power consumption, and ease of use. Here's an overview of the key
features and architecture of the PIC16 family:

Microchip PIC16 family


**Harvard Architecture**: The PIC16 microcontrollers use a dual-bus Harvard architecture,
which separates the program and data memory. This allows simultaneous access to both
memories, improving performance.

- **Instruction Pipelining**: The PIC16 family supports a two-stage instruction pipeline, which
helps in executing instructions more efficiently.

- **Wide Range of Peripherals**: These microcontrollers come with a variety of on-chip


peripherals, including timers, serial communication interfaces (UART, SPI, I2C), analog-to-
digital converters (ADC), and digital-to-analog converters (DAC).

- **Enhanced Mid-Range Family**: The PIC16F1xxx series is part of the enhanced mid-range
family, offering additional features such as enhanced memory management, interrupt
handling, and digital I/O capabilities.

- **Low Power Consumption**: Designed for low-power applications, these microcontrollers


are ideal for battery-operated devices.

### Architecture

- **Program Memory**: The PIC16 microcontrollers use flash memory for program storage,
allowing for easy reprogramming.

- **Data Memory**: The data memory includes registers, RAM, and EEPROM for data storage.

- **Interrupt Handling**: The PIC16 family supports multiple interrupt sources, allowing for
efficient handling of various events.
- **Digital I/O**: The microcontrollers provide a range of digital input/output pins for
interfacing with external devices.

### Applications

The PIC16 family is used in a wide range of applications, including:

- **Automotive Systems**: For engine control units, sensor interfaces, and other automotive
applications.

- **Consumer Electronics**: In devices like remote controls, toys, and home appliances.

- **Industrial Automation**: For controlling machinery, monitoring processes, and managing


automation systems.

- **Medical Devices**: In equipment such as patient monitors, diagnostic tools, and other
medical devices.

Microchip PIC16F873
The PIC16F873 is a popular microcontroller from Microchip Technology Inc. Here's an
introduction to this versatile little chip:

Key Features:

 CPU: It's built around an 8-bit PIC core. This might sound basic, but it's efficient
enough for many applications.

 Speed: The chip can operate at speeds up to 20 MHz.

 Memory:

o Program Memory (FLASH): 4K words

o Data Memory (SRAM): 192 bytes

o EEPROM: 128 bytes for non-volatile data storage

 Power: It has a range of operating voltages (2.0V to 5.5V), making it flexible for
various power supply conditions.

 I/O Ports: It supports a total of 22 I/O pins, offering multiple input and output
options.

 Timers: Three timers (Timer0, Timer1, Timer2) for precise timing and event
management.

 Communication: There's support for universal asynchronous receiver-transmitter


(USART) and synchronous serial port (SSP) with SPI™ and I²C™.
 Analog: It includes an analog-to-digital converter (ADC) with 8 channels and 10-bit

resolution, perfect for interfacing with various sensors.

"Hardware-software co-design" in embedded systems

"Hardware-software co-design" in embedded systems refers to the process of


designing both the hardware and software components of a system simultaneously
and in an integrated manner. This methodology aims to optimize the performance,
power, cost, and reliability of embedded systems by exploring the trade-offs between
hardware and software implementation.

Explanation:

1. Hardware-Software Partitioning: The design process begins by dividing the


system's functions into tasks handled by hardware and software.

2. Concurrent Development: Both hardware and software are developed concurrently


to ensure that they work seamlessly together.

3. Optimization: The co-design process aims to achieve the best balance between
hardware complexity and software flexibility.

4. System Validation: Regular testing and validation ensure that the combined
hardware and software meet the system's functional requirements.

Block Diagram:

Below is a conceptual block diagram of hardware-software co-design:

1. System Specification: Defines overall system requirements.

2. Hardware-Software Partitioning: Determines which functions go into hardware and


which into software.

3. Hardware Design: Involves designing processors, memory, and other physical


components.

4. Software Development: Includes programming, algorithm design, and real-time


operating systems (RTOS).

5. Integration: Combines hardware and software to form the complete embedded


system.

6. Validation and Testing: Ensures the system meets all requirements.

I can create a block diagram for better visualization. Let me know if you'd like one!

You might also like