Microcontrollers and embedded systems are often discussed in electronics and computing, but they lack strict, universally accepted definitions. For developers working in these fields, the distinction is often based on practical experience. This article explores the core concepts and differences between microcontrollers and embedded systems.
What is a Microcontroller?
A microcontroller is an integrated circuit that combines a central processing unit (CPU), random access memory (RAM), read-only memory (ROM), multiple input/output (I/O) ports, interrupt systems, and timers/counters into a single chip. Additional features, such as display drivers, pulse-width modulation circuits, analog multiplexers, or analog-to-digital converters, may also be included. This compact microcomputer system is widely used in industrial control applications.
Since the 1980s, microcontrollers have evolved from 4-bit and 8-bit designs to modern high-speed variants operating at up to 300 MHz. For example, the classic 51-series microcontroller is a thumb-sized chip with 40 pins, housing a logic processing unit equivalent to a basic CPU.
A microcontroller alone cannot perform complex applications without external components. Supporting elements like crystal oscillators, 5V power supplies, inductors, and resistors ensure its basic operation. To enable practical applications, peripherals such as buttons, LEDs, displays, buzzers, or sensors must be added. This combination of a microcontroller and peripherals forms the basis of many development boards available in the market.
In summary, a microcontroller is a standalone module designed for computation, logic control, and communication. Digital signal processors (DSPs) can also be considered a type of microcontroller, though their functionality remains focused on data processing and logic operations.
What is an Embedded System?
An embedded system is a specialized computer system integrated into a device or equipment, typically for control, monitoring, or auxiliary functions. According to the IEEE, an embedded system is defined as a device used to control, monitor, or assist in operating machines and equipment.
Embedded systems are application-centric, built on computer technology, and feature customizable hardware and software tailored to specific requirements for functionality, reliability, cost, size, power consumption, and operating environment. Devices with digital interfaces, such as watches, microwaves, video recorders, and vehicles, often incorporate embedded systems. While some embedded systems include operating systems, many rely on a single program to handle all control logic, particularly in industrial applications where fixed peripheral control ensures stability and reliability without human intervention.
Embedded systems encompass both hardware and software. In China, the widely accepted definition describes them as dedicated computer systems centered on specific applications, with customizable hardware and software designed to meet stringent requirements for functionality, reliability, cost, size, and power consumption.
Hardware Layer of Embedded Systems
The hardware layer of an embedded system includes an embedded microprocessor, memory (such as SDRAM, ROM, or Flash), general-purpose device interfaces, and I/O interfaces (e.g., analog-to-digital, digital-to-analog, or general I/O). A basic embedded control module is formed by combining an embedded processor with power circuits, clock circuits, and memory circuits. Both the operating system and application programs can be stored in ROM.
Embedded microprocessors differ from general-purpose computer CPUs, as they are designed for specific systems. For instance, companies like Texas Instruments and Atmel offer processors tailored for distinct applications, such as Atmel¡¯s SAM series for IoT or AVR series for industrial use due to their high performance.
Over 1,000 types of embedded microprocessors exist globally, spanning more than 30 architectural series, including ARM, MIPS, PowerPC, x86, and SH. Unlike the PC market, no single embedded microprocessor dominates. With over 100 types of 32-bit processors alone, the choice of processor depends on the specific application.
ARM-based processors are prevalent in embedded systems, with architectures like the Cortex series (part of ARMv7) supporting virtual-memory-based operating systems (Cortex-A), real-time systems (Cortex-R), or microcontrollers (Cortex-M). Embedded systems interact with the external environment through general-purpose interfaces like analog-to-digital converters, digital-to-analog converters, or I/O ports, enabling connectivity with peripherals. These peripherals, whether internal or external to the chip, range from simple serial communication devices to complex wireless modules like 802.11.
Common interfaces in embedded systems include RS-232 (serial communication), Ethernet, USB, audio, VGA, I2C, SPI, and IrDA, similar to those found in microcontroller systems.
Software Layer of Embedded Systems
The software layer of an embedded system includes the operating system, comprising the kernel, file system, and higher-level applications. Common embedded operating systems include Linux, Unix-like systems (e.g., FreeBSD, Solaris), and real-time operating systems (RTOS) such as VxWorks, RTEMS, or uC/OS.
Linux-based embedded systems often use distributions like Ubuntu, Red Hat, Debian, or CentOS, which share the Linux kernel but differ in software and tools. Standardized software, such as Apache for web servers or Samba for file servers, ensures compatibility across distributions. Standards like the Linux Standard Base further regulate development practices.
Real-time operating systems prioritize predictability in task execution, ensuring tasks complete within specified time constraints. The IEEE defines real-time systems as those whose correctness depends on both logical results and the time taken to produce them. RTOSes are categorized as hard real-time, where operations must complete within strict deadlines, or soft real-time, where operations are completed as quickly as possible based on task priority. Many general-purpose operating systems can be modified to function as real-time systems.
Key differences between real-time and time-sharing operating systems like Linux include:
- Multiplexing: Real-time systems handle multiple data inputs or control multiple devices, similar to time-sharing systems serving multiple users.
- Independence: Data collection and control operations in real-time systems are independent, as are user requests in time-sharing systems.
- Timeliness: Real-time control systems require response times in seconds, milliseconds, or even microseconds, compared to human-acceptable delays in time-sharing systems.
- Interactivity: Real-time systems offer limited interaction, typically accessing specific service programs, unlike the broader data processing and resource-sharing capabilities of time-sharing systems.
- Reliability: Real-time systems demand high reliability, with multi-level fault tolerance to prevent errors that could lead to significant economic or catastrophic consequences.
Due to their reliability and timeliness, real-time operating systems are widely used in industrial control, aerospace, and other critical fields. For example, NASA¡¯s recent Mars rovers employ the RTEMS real-time operating system.
Intermediate Layer of Embedded Systems
The intermediate layer, often referred to as the board support package (BSP), bridges the software and hardware layers. Though technically part of the software layer, it provides hardware drivers and configurations downward while offering standard APIs to software developers upward. Engineers working on this layer, known as embedded driver engineers, require expertise in both hardware characteristics and operating system knowledge to develop functional applications.
To determine whether an operating system supports a specific chip or development board, developers check if the system¡¯s source code includes the corresponding BSP.
Hardware Platforms for Embedded Systems
Embedded hardware platforms, such as the Raspberry Pi, are compact yet powerful. Despite its credit-card-sized form factor, the Raspberry Pi supports video, audio, and other functionalities. Similar platforms, like the BeagleBone Black, feature USB, Ethernet, SD card slots, and HDMI interfaces. These boards typically use ARMv7 processors, which offer improved performance over older ARMv6 architectures, including superscalar designs, SIMD instructions, and enhanced branch prediction.
ARMv7 processors are widely supported by modern operating systems, unlike ARMv6, which has been phased out by distributions like Ubuntu since 2012.
Comparison and Development Differences
Compared to embedded systems, microcontrollers have limited processing power, with clock speeds typically in the tens of MHz, versus hundreds or thousands of MHz for embedded processors. Microcontrollers lack graphical processing units (GPUs), making them unsuitable for graphical user interfaces. Their on-chip storage is often limited to a few kilobytes, restricting their ability to run operating systems or complex protocol stacks like TCP/IP or USB. High-end microcontrollers, such as STMicroelectronics¡¯ STM32 series, may support lightweight operating systems or embedded network stacks like lwIP.
Embedded processors, with hundreds of megabytes of RAM and expandable storage, can run full Linux systems, graphical interfaces, and advanced applications like network communication or video processing.
Development approaches also differ significantly. Microcontroller development often occurs in Windows-based integrated development environments (IDEs) like Keil, IAR, or Texas Instruments¡¯ Code Composer Studio. These tools integrate compilation, assembly, linking, and debugging with user-friendly interfaces, allowing developers to write C code, compile, and debug efficiently.
Embedded development, however, is typically conducted in Linux environments. Developers compile code on a host machine, often with an x86 architecture, for target processors like ARM or SPARC, requiring a cross-compilation toolchain. Compilation and linking are managed manually using GNU Make, Makefiles, and configure scripts, executed in a Linux terminal. This process increases the complexity of embedded development compared to microcontroller development.