Embedded Systems in Electronic Engineering

As the upgrade of traditional industrial structure accelerates in our country, the increasing application demands for devices can no longer meet the current and future high-performance application and development requirements. At the same time, fierce market competition and technological competition require shorter product development cycles. Clearly, the software and hardware technologies of embedded systems and development methods are receiving increasing attention, becoming an important foundation for technological innovation in various fields.

Embedded Systems in Electronic Engineering

Embedded Systems

According to the definition by IEEE (Institute of Electrical and Electronics Engineers), an embedded system is a device used to control, monitor, or assist in the operation of equipment, machinery, and workshops.

A commonly accepted definition in China is: an application-centered, computer technology-based, software and hardware customizable, dedicated computer system that meets the strict requirements of application systems for functionality, reliability, cost, size, and power consumption.

Unlike general computer systems, embedded systems are a type of computer system that does not appear as an independent physical device. The components of embedded systems are embedded within the main device according to the needs of the main device and its applications, performing functions of computation, processing, storage, and control. They are devices “used to control, monitor, or assist in the operation of machines and equipment.”

It can be considered that embedded systems are a type of dedicated computer system that acts as part of a device or equipment. An embedded system generally consists of four parts: an embedded microprocessor, peripheral hardware devices, an embedded operating system, and user applications. The three basic elements of “embeddedness,” “dedicated nature,” and “computer system” define embedded systems, while the object system refers to the host system into which the embedded system is embedded.

Components of Embedded Systems

Embedded systems typically consist of an embedded computer system that includes an embedded processor, embedded operating system, application software, and peripheral device interfaces, along with the execution device (the controlled object). The embedded computer system is the core of the entire embedded system, which can be divided into hardware layer, intermediate layer, system software layer, and application software layer. The execution device receives control commands issued by the embedded computer system and performs the specified operations or tasks.

Embedded Systems in Electronic Engineering

1. The Hardware Layer of Embedded Computer Systems

The hardware layer includes embedded microprocessors, memory (SDRAM, ROM, Flash, etc.), general device interfaces, and I/O interfaces (A/D, D/A, I/O, etc.). The hardware layer is typically a circuit module centered around an embedded processor, containing power circuits, clock circuits, and memory circuits, where the operating system and application programs are embedded in the module’s ROM.

1.1 Embedded Microprocessor

Embedded Systems in Electronic Engineering

The embedded microprocessor is the core of the hardware layer of embedded systems. The embedded microprocessor integrates many tasks that are typically completed by circuit boards within the general CPU into a single chip, facilitating a design that is compact, efficient, and reliable. Most embedded microprocessors operate in systems specifically designed for particular user groups. The architecture of the embedded microprocessor can adopt the Von Neumann architecture or Harvard architecture, and the instruction set can choose between Reduced Instruction Set Computer (RISC) and Complex Instruction Set Computer (CISC).

There are various architectures for embedded microprocessors, with over 1000 types available worldwide, and more than 30 series of architectures, including mainstream architectures such as ARM, MIPS, PowerPC, and X86. Even within the same architecture, there can be different clock frequencies, data bus widths, interfaces, and peripherals. Currently, no single embedded microprocessor dominates the market; the choice of embedded microprocessor is determined by specific applications.

1.2 Memory

The memory of embedded systems includes Cache, main memory, and auxiliary storage, used to store and execute code.

Embedded Systems in Electronic Engineering

Cache is a fast memory array located between the main memory and the embedded microprocessor, storing the program code and data that the microprocessor has used most frequently in recent periods.

Cache is generally integrated within the embedded microprocessor and can be divided into data Cache, instruction Cache, or mixed Cache, with the storage capacity varying depending on different processors.

Main memory is used to store system and user programs and data, and is the memory that the embedded microprocessor can directly access. Main memory includes ROM and RAM and can be located internally or externally to the microprocessor. Common types of ROM include NOR Flash, EPROM, and PROM, while RAM types include SRAM, DRAM, and SDRAM, with capacities ranging from 256KB to 1GB.

Auxiliary storage typically refers to hard drives, NAND Flash, CF cards, MMC, and SD cards, used to store large amounts of program code or information, generally with larger capacities but slower read speeds compared to main memory.

1.3 General Device Interfaces and I/O Interfaces

Embedded systems typically have the general device interfaces required for interaction with the outside world, such as GPIO, A/D (analog-to-digital conversion interface), D/A (digital-to-analog conversion interface), RS-232 interface (serial communication interface), Ethernet (Ethernet interface), USB (Universal Serial Bus interface), audio interfaces, VGA video output interfaces, I2C (field bus), SPI (serial peripheral interface), and IrDA (infrared interface), etc.

2. Intermediate Layer

The intermediate layer, also known as the Hardware Abstract Layer (HAL) or Board Support Package (BSP), is located between the hardware layer and software layer, separating the upper layer software from the lower layer hardware.

BSP serves as the interface between upper layer software and hardware platforms, providing methods for the operating system to operate and control specific hardware. Different operating systems have their own software hierarchy, and BSP needs to provide specific hardware interface forms for different operating systems. BSP allows upper layer software developers to focus on development without worrying about the specifics of lower layer hardware, using the interfaces provided by the BSP layer.

BSP is a software layer that sits between the operating system and lower layer hardware, including most software modules closely related to hardware in the system. BSP generally includes functions such as the initialization of relevant lower layer hardware, data input/output operations, and hardware device configuration.

2.1 Initialization of Embedded System Hardware

The system initialization process can be divided into three main stages in a bottom-up order, from hardware to software: chip-level initialization, board-level initialization, and system-level initialization.

Chip-level initialization is a purely hardware initialization process that includes setting the core registers and control registers of the embedded microprocessor, core operating modes of the embedded microprocessor, and local bus modes of the embedded microprocessor, etc.

Board-level initialization is an initialization process that includes both software and hardware, completing the initialization of hardware devices other than the embedded microprocessor, setting certain software data structures and parameters, and establishing the hardware and software environment for subsequent system-level initialization and application program execution.

System-level initialization primarily involves the initialization of the operating system. BSP transfers control of the embedded microprocessor to the embedded operating system, which completes the remaining initialization operations. Finally, the operating system creates the application program environment and transfers control to the entry point of the application program.

2.2 Hardware-Related Device Drivers

BSP includes hardware-related device drivers, but these device drivers are usually not directly used by BSP. Instead, during the system initialization process, BSP associates them with the general device drivers in the operating system, which are then called by the general device drivers in subsequent applications to operate the hardware devices.

3. System Software Layer

The system software layer typically includes the Embedded Operating System (EOS), file systems, network systems, and general component modules.

3.1 Embedded Operating System

EOS not only possesses the basic functions of general operating systems such as task scheduling, synchronization mechanisms, interrupt handling, and file processing, but also has the following characteristics:

  • Strong real-time performance;

  • Support for open and scalable architectures with customizability;

  • Provide a unified device driver interface;

  • Support TCP/IP protocols and other protocols, providing TCP/UDP/IP/PPP protocol support and a unified MAC access layer interface, offering powerful networking capabilities;

  • The user interface of the embedded operating system provides services to user programs through system call commands;

  • Once the embedded system starts running, it does not require excessive user intervention;

  • The embedded operating system and application software are embedded in the ROM of the embedded system computer;

  • Good hardware adaptability (portability).

3.2 File System

The embedded file system primarily provides functions for file storage, retrieval, and updating. The embedded file system typically supports several standard file systems such as FAT32, JFFS2, and YAFFS, and some embedded file systems also support custom real-time file systems.

The embedded file system provides various operations on files through system calls and commands, such as setting and modifying access permissions for files and directories, providing services for creating, modifying, changing, and deleting directories, and providing services for creating, opening, reading, writing, closing, and revoking files.

4. Application Software Layer

The application software layer is used to implement control functions for the controlled objects and consists of the developed application programs, targeting controlled objects and users.

Embedded Real-Time Operating Systems

RTOS, unlike general computer systems, requires that tasks in the system not only produce correct results but must also be completed within certain time constraints (Deadline). In an RTOS, a logically correct computational result that is produced later than a specified time is considered incorrect system behavior.

Embedded Systems in Electronic Engineering

1. Definition of Real-Time Systems RTOS

RTOS refers to systems that can complete system functions and respond to external or internal events, either synchronously or asynchronously, within specified or determined time frames. The system can handle and store large amounts of data required by the control system. The correctness of RTOS depends not only on the logical results of the system’s computations but also on the timing of when these results are produced.

2. Characteristics of RTOS

2.1 Constraints

RTOS tasks are subject to constraints including time constraints, resource constraints, execution order constraints, and performance constraints.

Tasks in RTOS have time constraints, which can be divided into “hard real-time” and “soft real-time”.

Resource constraints refer to the need for multiple real-time tasks to synchronize when sharing limited resources, following certain resource access control protocols to avoid deadlocks and unpredictable priority inversion times (i.e., the time when a high-priority task is blocked by a low-priority task).

Performance constraints refer to the need to meet performance indicators such as reliability, availability, predictability, and Quality of Service (QoS).

2.2 Predictability

Predictability means that the execution time required for RTOS to complete real-time tasks should be known.

2.3 Reliability

Most RTOS require high reliability, ensuring that the system can operate normally or avoid losses even under the worst conditions. Reliability is an important performance indicator of RTOS.

n(4) Interactivity nThe external environment is an indispensable component of RTOS, often representing the controlled subsystems, with both interacting to form a complete real-time system.

3. RTOS Scheduling

The entire process of determining when and where each task is executed, given a set of real-time tasks and system resources, is scheduling. The purpose of scheduling in RTOS is to ensure that each task meets its time constraints and responds promptly to external requests.

4. Classification of RTOS

RTOS is mainly divided into two categories: hard real-time systems and soft real-time systems. Hard real-time systems are applied in aerospace, military, nuclear industries, etc., while soft real-time systems include video on demand systems, information collection and retrieval systems, etc.

Embedded Microprocessor Architectures

1. Von Neumann Architecture and Harvard Architecture

1.1 Von Neumann Structure

The Von Neumann structure consists of a CPU and memory, where program instructions and data share a single storage space, with program instruction storage addresses and data storage addresses pointing to different physical locations in the same memory; it uses a single address and data bus, with the same width for program instructions and data. The program counter (PC) is a register within the CPU that indicates the storage location of instructions and data.

The CPU addresses memory using the address information provided by the program counter to find the required instruction or data, then decodes the instruction and finally executes the operations specified by the instruction. When the processor executes an instruction, it first fetches the instruction from memory, decodes it, and then fetches the operands to perform the computation. Even a single instruction can consume several or even dozens of cycles, which can lead to bottlenecks in high-speed computations during transmission.

CPUs and microcontrollers that use Von Neumann architecture include Intel’s 8086 series and other CPUs, ARM’s ARM7, MIPS’s MIPS processors, etc.

1.2 Harvard Structure

The main feature of Harvard architecture is that programs and data are stored in separate storage spaces, meaning that program memory and data memory are two independent memories, each independently addressed and accessed. The system has separate buses for program data and address lines, and for data data and address lines.

This separation of program and data buses allows for simultaneous fetching of instruction words (from program memory) and operands (from data memory) within a single machine cycle, thereby improving execution speed and increasing data throughput. Since program and data memories are in two separate physical spaces, instruction fetching and execution can completely overlap, resulting in higher execution efficiency.

Currently, many CPUs and microcontrollers use Harvard architecture, including Motorola’s MC68 series, Zilog’s Z8 series, ATMEL’s AVR series, and ARM’s ARM9, ARM10, and ARM11, etc.

2. Reduced Instruction Set Computer (RISC)

Early computers adopted Complex Instruction Set Computer (CISC) architecture. In CISC, many complex instructions were added to support optimization of target programs, support high-level languages and compilers, resulting in highly irregular control logic, causing significant difficulties for VLSI technology.

Reduced Instruction Set Computer (RISC) architecture emerged and developed based on CISC, focusing not merely on simplifying the instruction set, but on simplifying the structure of the computer to enhance computational efficiency.

RISC uses Load/Store instructions to access memory, with other operations occurring between registers; it increases the number of general-purpose registers, with operands for arithmetic logic operations stored in general-purpose registers; most instructions are controlled to complete within one or fewer machine cycles; it primarily uses hardwired control logic, minimizing or eliminating microcode control; it emphasizes high-level language programming and compiler optimization to reduce program execution time.

3. Pipelining Technology

Pipelining technology is applied in various aspects of computer system architecture, breaking down a repetitive timing sequence into several subprocesses, each of which can be effectively executed simultaneously in its dedicated functional segment. The time required to achieve the functionality of subprocesses should be as equal as possible. Establishing a pipelined process requires a preparation time. If the instruction stream cannot be executed sequentially, it will interrupt the pipelined process, and re-establishing the pipelined process will require time.

4. Byte Order of Information Storage

4.1 Big-endian and Little-endian Storage Methods

For multi-byte data types, there are two storage methods in memory. In little-endian byte order, low-byte data is stored at lower memory addresses, and high-byte data is stored at higher memory addresses.

In big-endian byte order, high-byte data is stored at lower memory addresses, and low-byte data is stored at higher memory addresses.

4.2 Portability Issues

When porting programs between microprocessors with different storage orders, special attention must be paid to the impact of storage patterns. Writing binary data obtained from software into a general data format often involves storage order issues.

4.3 Storage Order Issues in Communication

In network communication, the Internet Protocol (IP) defines a standard network byte order. This byte order is used in all data packets, high-level protocols, and file formats designed for use with the IP protocol. Many network devices also have storage order issues: bits within bytes may be sent using big-endian (most significant bit first) or little-endian (least significant bit first) order, depending on the lowest layer of the OSI model, the data link layer.

4.4 Storage Order of Data Formats

Types of Embedded Processors

1. Embedded Microcontroller (MCU)

Also known as a single-chip microcontroller, the chip integrates various necessary functions and peripherals such as ROM, EPROM, RAM, buses, bus logic, timers/counters, watchdogs, I/O, serial ports, PWM output, A/D, D/A, Flash, EEPROM, etc.

Embedded microcontrollers are characterized by being single-chip, compact, low power consumption, low cost, and high reliability, accounting for about 70% of the embedded systems market share.

Embedded Systems in Electronic Engineering

2. Embedded Microprocessor (MPU)

Developed from general-purpose computer CPUs, embedded microprocessors retain only the functions closely related to embedded applications, removing redundant functional parts to achieve the special requirements of embedded applications with minimal power consumption and resources.

Embedded Systems in Electronic Engineering

3. Embedded DSP

Embedded DSP is a processor specifically designed for signal processing, featuring special designs in system architecture and instruction algorithms, resulting in high compilation efficiency and instruction execution speed.

Embedded Systems in Electronic Engineering

4. System on Chip (SoC)

SoC, System on Chip, is defined as: based on intellectual property cores for design, integrating processors, memory, various interfaces, and other components on a single chip, forming a relatively complete computer system that can perform specific application functions.

Currently, most 32-bit embedded processor chips are SoCs. Embedded SoCs pursue maximum integration of system components, with the vast majority of system components located within a single system chip.

5. Multi-core Processors

Packaging two or more CPU cores within a single chip can save a significant amount of transistor and packaging costs while also significantly improving processor performance, enabling coordinated operation of two or more cores.

Embedded Systems in Electronic Engineering

History of Embedded Systems Development

1. Systems based on single-chip programmable controllers. Generally without operating system support, directly controlled through assembly language.

In the 1970s, the world’s first microprocessor, Intel 4004, marked a significant milestone in the development of embedded applications.

2. Embedded systems based on embedded CPUs with simple operating systems.

Supported by simple operating systems, but with weaker universality.

In the 1980s, single-chip microcontrollers emerged – Intel further improved the 8048 and developed the 8051 single-chip microcontroller based on it, and subsequently, DSP products rapidly advanced the technical level of embedded systems.

In 1981, the first commercial embedded real-time kernel (VTRX32) appeared, followed by the emergence of several embedded operating systems.

3. Embedded systems marked by embedded operating systems.

Good compatibility.

From the 1990s to the present, developments in hardware, especially in chips, exhibit three characteristics:

In software, embedded operating systems have further diversified, giving rise to several families of embedded operating systems.

Cross-platform software development technology has expanded from general-purpose computers to embedded devices.

4. Embedded systems marked by the Internet.

Combined with the Internet.

Embedded controllers are ubiquitous: mobile phones, home appliances, cars… all have their traces. Due to their small size, high reliability, strong functionality, and flexibility, embedded controllers have penetrated various fields such as industry, agriculture, education, national defense, scientific research, and daily life, playing a crucial role in technical transformation, product upgrades, accelerating automation processes, and improving productivity in various industries. Since the 1990s, embedded technology has unfolded comprehensively, becoming a common development direction for communication products and consumer products, widely applied in telecommunications, broadcasting, and television fields. In personal domains, embedded products are primarily used commercially, becoming popular as personal mobile data processing and communication software. The development space for embedded system technology is immense.

Source: Sensor Technology

Leave a Comment