Embedded systems¶
Learning goals:
After studying this material, you will know what embedded systems are, what hardware-oriented programming means, what the main characteristics of embedded systems are, and how embedded devices are programmed.
Embedded systems - Why?¶
Embedded system is a device or a system that is controlled by a computing device and specifically made to perform a dedicated task. In this kind of system, users do not usually need to be aware of the computer inside the device, even though its existence can often be deduced. Embedded systems are widely used today in various application areas:
- Home appliances, entertainment electronics, smartphones, air conditioning, elevators, …
- Cars, airplanes, trains, … (multiple internal embedded systems)
- Health technology: hospital equipment, remote diagnostics, heart rate monitors, …
- Industrial automation: robotics, process control and monitoring, …
- Space technology: satellites, probes, …
- Future (and even the present): smart transportation, intelligent environments, wearable technology, …
Hardware-oriented programming, refers to computer programming where programs are developed very close to the computer's hardware, meaning its physical components and parts. This can involve directly controlling the electronic signals that enable different components to function. Nowadays, however, these functionalities are abstracted into layers and existing libraries, making embedded programming significantly easier, as you'll see later in the course.
Embedded systems at work.. and as a hobby. Easier than it seems!
Internet of Things¶
In the course, we operate in the environment of theIoT. IoT refers to an ecosystem of physical devices and objects connected through communication networks, allowing them to collect, exchange, and use data. Nowadays, the Internet of Things has two main perspectives.
- Consumer and Societal Perspective: The Internet of Things enables new applications in the field Ubiquitous Computing/Smart Environments/Ambient Intelligence: smart environments, services, and applications for consumers, businesses, and society. Individual devices and applications collect data about their environment and operations, becoming part of an ecosystem. Examples include real-time monitoring of urban events such as traffic flow, energy consumption in cities/homes, tracking human activities (health technology), and remote control of home appliances.
- Industrial Perspective: Another significant application area for IoT solutions is Industrial Internet of Things a pillar of Industry 4.0. Here, embedded systems are used at the level of individual system components. For example, they automate entire factory operations, monitor production processes, and optimize them using Big data. This can involve for example managing energy consumption or logistics. As a result, a factory floor may have (tens of) thousands of interconnected embedded systems via various networks.
You can see a short introduction video
The components of an embedded device¶
An embedded device is a resource-constrained microcomputer designed and functioning specifically for a particular purpose, in contrast to a general-purpose workstation like a home PC. Compared to a PC, an embedded device typically includes only the essential components necessary for its intended use.
The operation of an embedded device generally involves receiving inputs (such as sensor data) related to the behavior of a larger system (e.g., a washing machine or a car) or environmental observations (e.g., greenhouse temperature). The device's program then responds to these inputs based on its programmed logic. For instance, it might analyze simple events (such as exceeding an allowed temperature) based on data from sensors. Often, the program also generates an output (e.g., controlling a larger device using an actuator, like adjusting greenhouse ventilation).
The most visible part of an embedded device for the user is the user interface. Inputs to the device are provided through integrated physical components such as switches (buttons) or a control panel (touchscreen). The device produces responses either on a display (small LCD screen) or through audio signals (speaker) or light indicators (LEDs). However, depending on its purpose, an embedded device may not necessarily have a user interface—for example, when it is integrated into the control system inside a car.
The role of the microcontroller in the embedded device is to handle data processing, acting as the central unit or processor. It executes the program designed for the device.
The role of the microcontroller in the embedded device is to handle data processing, acting as the central unit or processor. It executes the program designed for the device.
The device may also include different types of non-volatile memory, such as an external SD memory card for larger amounts of data or EEPROM for storing smaller persistent values. Of course, an embedded device requires a power source, which, in a mobile device (like a pedometer), is typically a battery or rechargeable cell.
Designers of these devices select the necessary components, considering their physical size, electronic and physical characteristics (sensor measurement range), interfaces, power consumption, programming, and other factors. They create an embedded device where external and internal components are connected to create a functional product. In this video you can see how an embedded device works.
Designers of these devices select the necessary components, considering their physical size, electronic and physical characteristics (sensor measurement range), interfaces, power consumption, programming, and other factors. They create an embedded device where external and internal components are connected to create a functional product. In this video you can see how an embedded device works.
Microcontroller¶
A microcontroller (also known as a MCU) refers to a single integrated circuit that includes both the CPU and other functional electronic components. The microcontroller in an embedded device corresponds to a computer's microprocessor, but its features are trimmed compared to processors found in home PCs, for example. However, an MCU typically integrates the CPU, memory, clock circuitry, and several commonly used peripherals, such as UART interfaces, on the same chip. A microcontroller operates at a low clock frequency and has limited memory, which is further divided into separate program memory implemented using non-volatile memory such as ROM or Flash memory, and main memory (Random Access Memory, RAM) used by programs during execution. Devices often have various types of memory tailored to their specific purposes.
In modern embedded devices, such as smartphones or cars, there are multiple microcontrollers, each performing its own task. For instance, one MCU handles the device's operational logic, another focuses on wireless data transmission, and a third controls the display. This division of labor among microcontrollers enhances the efficiency of the device and its applications by distributing the program's workload across several microcontrollers. Notably, wireless data transmission is a resource-intensive operation in embedded devices, and using a single microcontroller might cause other functions to pause during data transfer
The embedded device of the course¶
The embedded devices used in the course are:
- Texas Instruments' Simplelink SensorTag (which we refer to as SensorTag), offering an excellent view into the current IoT world with its pre-integrated components!
- Raspberry Pi's Raspberry Pi Pico W (affectionately known as "Pico"), which provides an excellent perspective on the current IoT world, especially when used with its extension board!
SensorTag¶
At the heart of the device is a 32-bit microcontroller, which has an integrated wireless radio and its own secondary microcontroller for data transmission. The circuit board of the device is also connected to about ten motion and environment measuring sensors (accelerometer, gyroscope, temperature, light, humidity, and pressure sensors, as well as a magnetometer, compass, and microphone). On the same circuit board, there are also push buttons, LEDs, and a small speaker. External additional components for the device include, for example, a black-and-white LCD display.
The radio integrated into the SensorTag offers several different technologies for wireless data transmission, of which we will use 6LoWPAN technology on the 2.4GHz frequency band in the course (you don't need to know the details of this technology for the course). The teaching staff has implemented a ready-made library for data transmission between devices.
The SensorTag operates (when properly programmed) on a coin battery for up to weeks, thanks to the carefully optimized power consumption of the microcontroller and peripheral components.
As an example, the SensorTag and integrated LCD display could function as a smartwatch!
Raspberry Pi Pico W¶
At the heart of the device is a modern, dual-core RP2040 microcontroller. The Pico also includes an Infineon CYW43439 wireless chip, connected to the RP2040, which provides Wi-Fi and Bluetooth communication. Additionally, the device's extension board includes several sensors for measuring motion and environmental factors (such as acceleration, orientation, temperature, light, humidity, and a microphone). On the same circuit board, you'll find a button, an LED, and a small speaker. The extension board can also accommodate a black-and-white LCD display.
The integrated radio in the Pico supports various technologies for wireless data transfer. In this course, we'll focus on Wi-Fi technology (you don't need to know the details of this technology right now, though). The course staff has already implemented a ready-made library for wireless data transfer.
The integrated radio in the Pico supports various technologies for wireless data transfer. In this course, we'll focus on Wi-Fi technology (you don't need to know the details of this technology right now, though). The course staff has already implemented a ready-made library for wireless data transfer.
When properly programmed, the Pico can run on a coin cell battery for weeks, thanks to its minimal power consumption from the microcontroller and peripheral components.
Below is a diagram of the Pico and its pin layout (we'll revisit this later in the course).
Embedded system vs. PC¶
Compared to a general-purpose PC workstation, an embedded system is designed for a specific purpose. Its computational power, memory, and other resources are typically selected according to the requirements of that purpose, and are generally much more limited than those of a workstation. Consequently, it is cost effective to use an embedded device instead of general-purpose PC hardware, which generally can work with low-performance components, which in turn reduces the manufacturing cost of such device. For example, it would be inefficient to use a modern PC to just remotely open a garage door.
Example: The table below illustrates typical differences between a PC and a microcontroller-based embedded device from a hardware perspective. The values are only indicative and can vary considerably depending on the device and its intended use.
| Typical PC | Embedded device | |
| Clock frequency | 2-6GHz | 1MHz - 1GHz |
| RAM-memory | 16-64GB | 1kB - 16MB |
| 8kB - 32MB Flash program memory | ||
| Processor | 64bit | 8bit / 16bit / 32bit / Some 64bit |
| Mass storage | 512GB - 4TB (SSD) | Optional/external, for example an SD card |
| 0.5kB - 1MB non-volatile EEPROM/FRAM memory | ||
| Peripherals | Integrated sound card | Small buzzer, GPIO pins |
| Graphics card | Small LCD/OLED screen or e-paper display | |
| Keyboard and mouse | Button, slider, or a touch screen |
It is important to note that the values in the table mainly represent microcontroller-based embedded devices. More powerful devices can also be used as part of embedded systems. For example, single-board computers such as the Raspberry Pi provide considerably more computing resources and can approach the specifications of a PC. A Raspberry Pi 5, for example, has a 2.4 GHz quad-core 64-bit processor, can contain up to 16 GB of RAM, and supports high-speed mass storage such as NVMe SSDs. These devices can therefore run full operating systems such as Linux and are suitable for more computationally demanding embedded applications.
In addition, modern PC's use peripheral devices that run their own internal embedded system. Examples of devices like this are a network card or a printer
The design and implementation of an embedded device¶
Due to the wide range of application areas, use cases, and requirements, designing and implementing embedded devices requires expertise from multiple fields, making it a collaborative effort. In essence, familiarity with the domain - such as medicine or process industries - and understanding the operational context is essential. Additionally, expertise in areas like electronics, computer engineering, software engineering, telecommunications, automation, and even mechanics is typically necessary. Furthermore, when designing devices for consumer markets, experts in user interface design and industrial design also play a crucial role.
From the perspective of computer and software engineering, an embedded device involves designing and implementing the interface between hardware and software, which consists of various electronic and mechanical components. Depending on the application, real-time behavior and responsiveness can be critical. The system may need to respond to external events within predictable and sometimes strict time limits.. Moreover, fault tolerance and handling error situations are important, as embedded systems often operate autonomously without human intervention. To support the development of embedded systems, specific software engineering and production methods, as well as programming environments, have been created. These often include simulators and/or emulators to verify program correctness during development before prototypes are even deployed to the actual device.
While we won’t delve into software engineering specifics in this course, when programming, we will follow event driven paradigm for our embedded systems. The central idea is to create a program that responds appropriately to events generated by peripheral components (such as button presses, new sensor readings, timing signals, wireless messages, etc.). Event-driven approaches are commonly used in software development, including user interface implementations for web applications.
Running programs¶
There are significant differences in the execution of programs on a PC and an embedded device. In workstations, programs always run on top of an operating system (such as Windows, macOS, Linux, …), but in embedded systems, there are options based on the purpose and choices made during the design phase.
Embedded devices may run different types of operating systems depending on their resources and requirements. Small devices often use a lightweight real-time operating system (RTOS), while more powerful devices may run Linux or another more complete operating system. It provides minimal services for program execution and access to hardware resources.
Sometimes, there is no operating system in embedded devices because the purpose is so simple that it doesn't require operating system services. In such cases, embedded programs are typically implemented on top of firmware. When the device starts up, the firmware initializes first, and other programs start afterward. The firmware connects the components of the embedded device into a functional computer and provides a low-level programming interface for working with components, typically including device drivers and higher-level abstractions to facilitate programming. A well-known example of embedded firmware is the one used by the user-friendly Arduino platforms, which provides libraries and abstractions that simplify access to the microcontroller and its peripherals.
NOTE: The term firmware is used somewhat differently by different authors. For example, Stringham (Hardware/Firmware Interface Design, 2010) uses a broad definition in which firmware is software built into an embedded product and stored in non-volatile memory, and it may include drivers, an operating system, and application code. Similarly, Sloss, Symes and Wright (ARM System Developer's Guide, 2004) note that firmware can range from a complete embedded software system to only initialization and bootloader code. Other authors use the term more narrowly. For example, Valvano (Embedded Systems) describes firmware as low-level software that directly interacts with the hardware, while Sun et al. (Embedded Firmware Solutions, 2015) define it as a software layer between the hardware and the operating system, providing functions such as hardware initialization and abstraction. In this course, we mainly use firmware in this latter, narrower sense: a low-level software layer that provides initialization, drivers, libraries, and abstractions that facilitate the use of the microcontroller and its peripherals.
When programming embedded systems, the firmware can be compiled as part of the embedded program, or the firmware might already be present in the device's program memory, with only the developer's program being loaded during the programming process. In contrast, in the PC world, the BIOS (or more recently UEFI) primarily serves as low-level firmware that initializes hardware during the boot process and hands control over to the operating system. BIOS/UEFI services are typically not involved in programming tasks once the operating system is running. Instead, the operating system and its drivers handle hardware interactions, and programming is done at the software level using system calls when the software needs to access certain piece of hardware (e.g memory, hard drive, network card). More on that in the Computer Systems course section, for all students who are taking the second part of the course.
It's also possible to implement an embedded application without firmware (so-called bare-metal), but in that case, the programmer needs to create the necessary peripheral interfaces and drivers, including initialization and setup. In bare-metal, programmer needs to control GPIO pins and different registers of the MCU. This naturally requires a deeper understanding of the microcontroller and the electronic operation and control of peripherals. In order to program bare-metal it is necessary to go carefully through the datasheet of the microcontroller or sensor developer is using.
In this course, we'll be creating programs for the Pico and SensorTag on top of a real-time operating system, using manufacturer libraries for assistance. The SDK (Software Development Kit) provided by manufacturers offers pre-implemented services, interfaces, and drivers, so we don't need to create them ourselves—only the functionality required by the application.
Programming an embedded device¶
When an embedded device starts up, its low-level firmware first performs the necessary initialization of the microcontroller and peripherals. After initialization, control is transferred to the application program. After initialization, the application program normally continues to run until the device's power is cut off or a fault occurs. Other events, such as a system reset, watchdog timeout, or software error, may also interrupt normal operation or cause the system to restart. Traditionally, many embedded devices were designed to run the same program throughout their lifetime. Updating them could be costly because it might require manual reinstallation or, in some cases, even a product recall. Today, however, embedded software is increasingly updated after deployment, especially in connected devices, using local or over-the-air (OTA) update mechanisms.
Even today, embedded systems are often programmed using the C programming language (and also its more modern counterpart, C++). Although C was developed in the 1970s, it remains popular for writing efficient, low-level code specifically for embedded systems. C is also a permissive language, allowing programmers to perform many low-level tasks that might not be possible in other languages. Although C and C++ remain widely used in embedded systems, Rust has emerged as another option for embedded programming, particularly where memory safety is important.
Programming for embedded devices typically occurs in a PC or workstation environment using development tools provided by the device manufacturers (often available for free). Embedded systems can be programmed using both compiled and interpreted languages. In this course, however, we use compiled C, so the program is compiled on the workstation before being loaded onto the device. In this case, the process of programming an embedded device involves several steps:
- The C program is first compiled on the workstation into machine code for the chosen microcontroller.
- The resulting code is then linked with the required firmware and other libraries and drivers to create the final executable program.
- The combined program is written (flashed) to the embedded device's program memory. Depending on the device, this can be done directly through USB or using a separate programming/debugging tool.
- During development and testing, the program's execution on the device can be controlled using a Debugger. Debuggers allow the programmer to examine the code, program state, and memory contents, and to control execution using features such as breakpoints and single-stepping.
In the picture below, the SensorTag's programming and debugging device (visible circuit board) that we will use in the course. The device is connected to the PC via a USB connector.
In the course, SensorTag is programmed in the C language using the manufacturer's development environments, primarily in the Code Composer Studio. We will programme the Pico using the C language within a Visual Studio Code-based development environment. We'll leverage the Pico SDK's libraries and drivers to implement our programs.
Detailed instructions for using the software and environment will be covered in the course's lab exercises, so hold off on any installations for now.
Challenges¶
When designing and programming embedded systems, it’s essential to consider several factors, including:
- Microcontrollers often have restricted computational capacity, even though hardware may have strict timing requirements (e.g., in factory applications).
- Small memory sizes limit both computation and data transfer capacity.
- Communication with peripheral devices is often constrained by the available interfaces, bandwidth, and hardware resources.
- Some devices lack an operating system, while others use highly trimmed-down Real Time Operating Systems
- For battery-powered or battery-operated embedded devices, optimizing power consumption is crucial during design.
We'll delve into these topics in more detail in the course material...
To conclude¶
Embedded system hardware platforms are available for hobbyists to use at home from various major microcontroller manufacturers, typically costing a few tens of euros. The best-known platform is probably the hobbyist-friendly Arduino. Arduino originally became popular through boards based on 8-bit AVR microcontrollers from Atmel (now Microchip), such as the ATmega328P used in the Arduino UNO R3. Today, the Arduino ecosystem includes both these classic 8-bit boards and newer boards based on 32-bit microcontrollers, such as the Renesas RA4M1 Arm Cortex-M4 used in the Arduino UNO R4. Arduino provides a simplified programming environment based on C++, together with libraries that make programming microcontrollers accessible even with limited programming experience. For example, Arduino is used in digital media education. While Arduino is too simplified for our course, having knowledge of its programming can still be beneficial.
It's important not to confuse the Pico with other more complex devices offered by Raspberry Pi (such as the Raspberry Pi 5). These devices are single-board computers with considerably more resources than typical microcontroller-based embedded devices. For example, the Raspberry Pi 5 has a 2.4GHz quad-core 64-bit processor and can have up to 16GB of RAM. These devices are more like Single Board Computer. Raspberry Pi devices often run Linux operating systems, which would be too heavy for Arduino. Some people don't consider the Raspberry Pi a true embedded system, but it can certainly be embedded in various environments of ubiquitous computing, much like Arduino.
Additional bibliography¶
Refer to the course book Embedded Systems
Give feedback on this content
Comments about this material