Introduction to
Embedded Systems
Syllabus
This module will cover the following aspects
• An overview of embedded systems
• Examples of embedded systems
• Features of embedded systems
• Software for embedded systems
• Embedded systems programming and debugging
2 © 2020 Arm Limited
What are Embedded systems?
3 © 2020 Arm Limited
An embedded system example -- a digital camera
Digital camera chip
CCD
CCD preprocessor Pixel coprocessor D2A
A2D
lens
JPEG codec Microcontroller Multiplier/Accum
DMA controller Display ctrl
Memory controller ISA bus interface UART LCD ctrl
• Single-functioned -- always a digital camera
• Tightly-constrained -- Low cost, low power, small, fast
• Reactive and real-time -- only to a small extent
4 © 2020 Arm Limited
Embedded systems
What is an embedded system?
• Application-specific computer system
• Built into a larger system Environment
• Often with real-time computing constraints
Why add an embedded computer to a larger Embedded system
system? Software
• Better performance
Input Hardware Output
• More functions and features
• Lower cost, for e.g., through automation
• More dependability
Examples: smartphones, smart watches, printers, User interface Other systems
gaming consoles, wireless routers
5 © 2020 Arm Limited
Embedded Systems
• System structure: Microcontroller
• Sensors: to retrieve data from its RTOS
environment
• ADC: converts the analog data from the Task 1 Task 2 Task n
sensor to digital signals
• Controller: the brain of the system; execute a
set of real-time tasks concurrently, may or
may not be with the support of a RTOS
A/D D/A
• Actuators: through actuators the controller
acts upon the target system
• DAC: convert the digital signals from
microcontroller to the analog signal Sensors Actuators
Target System
6 © 2020 Arm Limited
What are differences between embedded computers and
general-purpose computers (PCs, Laptops)?
7 © 2020 Arm Limited
Embedded Computer vs. General-purpose Computer
How the computing machine is used?
Embedded System General-purpose computer
- A component of some larger product; its - A complete product itself
purpose is narrowly focused on supporting that
product
- End user of the product typically does not - End user directly interacts with it
directly interact with the embedded system, or
interacts with only a limited interface
- User don’t consider the product (e.g. DVD - User explicitly knows the product they are
players, MP3 players, game consoles) they are buying is a computer
buying is a computer
8 © 2020 Arm Limited
Embedded Computer vs. General-purpose Computer
How the computing machine is used?
Embedded System General-purpose computer
- Having some of these standard peripherals as - Having relatively few, standardized inputs and
well, but also include much more specialized outputs: keyboards, mice, network connections,
ones: video monitors, and printers
+ special-purpose sensors: accelerometers,
temperature probes, magnetometers, push
button contact switches, etc.
+ special-purpose outputs: lamps and LEDs,
actuators, TTL electrical signals, LCD displays, etc.
9 © 2020 Arm Limited
Embedded System Definition
“Embedded systems are computing systems with tightly coupled hardware
and software integration, that are designed to perform a dedicated
function. The word ‘embedded’ reflects the fact that these systems are
usually an integral part of a larger (mechanical or electrical)
system/product, known as the embedding system. Multiple embedded
systems can coexist in an embedding system.” – (Qing Li and Carolyn Yao)
10 © 2020 Arm Limited
Embedded Computing System
• Embedded systems can be classified based on their complexity and performance into:
• Small-scale systems
– Perform simple functions, operate on battery, no operating system
– usually built around low-end 8- or 16-bit microprocessors or microcontrollers
– main programming tools: an editor, assembler, cross-assembler, and integrated development environment (IDE).
– Examples: mouse and TV remote control
• Medium-scale systems
– have both hardware and software complexities, have operating system support
– use 16- or 32-bit microprocessors or microcontrollers
– main programming tools are C, C++, JAVA, Visual C++, debugger, source-code engineering tool, simulator, and IDE
– Examples: vending machines and washing machines
• Large-scale or sophisticated systems
– have enormous hardware and software complexities
– built around 32- or 64-bit microprocessors or microcontrollers, along with a range of other high-speed integrated
circuits.
– need hardware and software co-design techniques
– Examples: flight-landing gear systems, car braking systems, and military applications
11 © 2020 Arm Limited
Microprocessor (μP) vs. MCUs vs. Embedded Systems?
12 © 2020 Arm Limited
Microprocessors → MCUs → Embedded Systems
Microprocessor or Central Processing unit (CPU)
Control Unit
Memory interface
Defined typically as a single processor
To program
Instruction fetcher core that supports at least instruction
memory blocks
fetching, decoding, and executing
Instruction decoder
Register banks Used for general purpose computing,
To data but needs to be supported with memory
memory blocks and Input/Output (I/O) interfaces
ALU
Microprocessor
Datapath
13 © 2020 Arm Limited
Basic Microprocessor Architecture
• Processor = Central processing Processor
Unit (CPU) Control unit Datapath
– CPU fetches instructions from ALU
Controller
memory. Control
/Status
• Separating CPU and memory that
distinguishes programmable Registers
computer from a general finite-
state machine.
– CPU registers: program counter PC IR
(PC), instruction register (IR),
general-purpose registers, etc.
I/O
Memory
14 © 2020 Arm Limited
14
Basic Microprocessor Architecture: Datapath
• Function Processor
• transforming data and storing temporary Control unit Datapath
data ALU
• Structure: Controller Control
/Status
• ALU (arithmetic-logic unit ): transforming
data through operations Registers
• Registers: storing temporary data
• internal data bus
10 11
PC IR
I/O
...
Memory
10
...
11
15 © 2020 Arm Limited
15
Basic Microprocessor Architecture: Datapath Operations
• Load Processor
Control unit Datapath
• Read memory location into register
ALU
Controller Control +1
• ALU operation /Status
– Input certain registers through Registers
ALU, store back in register
10 11
• Store PC IR
– Write register to memory
location
I/O
...
Memory
10
...
11
16 © 2020 Arm Limited
16
Basic Microprocessor Architecture: Control Unit
• Control unit: configures the datapath
operations Processor
Control unit Datapath
• Sequence of desired operations ALU
(“instructions”) stored in memory – “Program” Controller Control
/Status
• Instruction cycle – broken into several sub-
operations, each one clock cycle, e.g.: Registers
• Fetch: Get next instruction into IR
• Decode: Determine what the instruction PC IR R0 R1
means
• Load operands: Move data from memory to I/O
...
datapath register 100 load R0, M[500] Memory
500 10
101 inc R1, R0
501 ...
• Execute: Move data through the ALU 102 store M[501], R1
• Store results: Write data from register to
memory
17 © 2020 Arm Limited
17
Microprocessors → MCUs → Embedded Systems
Microcontroller Unit (MCU)
Microprocessor Program memory Data memory
System Bus
Digital I/O Analog I/O Timers Other peripherals
MCU
Single-chip computer typically has a single microprocessor core
Has memory blocks, digital I/Os, analog I/Os, and other basic peripherals
Used for basic control purposes, such as embedded applications
18 © 2020 Arm Limited
Microprocessor vs. Microcontroller
Microprocessor Microcontroller
A microprocessor is a single-chip CPU. A microcontroller is one form of a single-chip
In addition to the memory, we also need I/O devices computer that includes a processor, memory, and I/O
to build a useful system. devices.
Microprocessor are designed to perform unspecific Microcontrollers are designed to perform specific
tasks tasks.
- the relationship of input and output is not defined. - the relationship of input and output is defined.
- high amount of resources like RAM, ROM, I/O - small resources like RAM, ROM, I/O ports
ports
The clock speed of the Microprocessor is quite high as compared to the microcontroller.
- Microcontrollers operate from a few MHz to 30 to 50 MHz,
- Microprocessors can operate up to 5GHz
19 © 2020 Arm Limited
19
CPUs → MCUs → Embedded Systems
Embedded system
Typically implemented using MCUs
Often integrated into a larger mechanical or electrical system
Usually has real-time constraints
Embedded
system
20 © 2020 Arm Limited
Embedded system example: Bike computer
Inputs:
Wheel rotation
• Functions Mode key
• Speed, cadence, distance, heart rate (HR) measurements
• Constraints
• Size, weight, and cost; power and energy
• Inputs
• Wheel rotation sensor and mode key
• Output
• Liquid crystal display (LCD), BLE interface to smartphone
• Uses low performance microcontroller Outputs:
Display/transmit
speed, HR, etc.
21 © 2020 Arm Limited
Embedded system example: Gasoline engine control unit
• Functions • Many inputs and outputs
• Fuel injection • Discrete sensors and actuators
• Air intake setting • Network interface to rest of the car
• Spark timing
• Exhaust gas circulation • Uses high performance microcontroller
• Electronic throttle control • E.g., 32-bit, 3MB flash memory, 150–300MHz
• Knock control
• Constraints
• Strict real-time constraints
• Reliability in a harsh environment
• Low Cost
• Small Weight
22 © 2020 Arm Limited
Implementing Embedded Systems:
Programming Microprocessors Vs. Designing Digital Circuits
Programmed Custom designed
Desired motion-at-night detector digital circuit • Microprocessors is a
microprocessor common choice to
implement a digital system
• Easy to program
• Cheap (as low as $1)
• Available now
I0 P0 void main() 1
I1 P1 a
{ 0
I2 P2 while (1) { 1
I3 P3 P0 = I0 && !I1; b
I4 P4 0
// F = a and !b,
I5 P5 1
I6 P6 } F
0
I7 P7 }
6:00 7:05 7:06 9:00 9:01 time
Microprocessor
Timing diagram
23 © 2020 Arm Limited
Embedded Systems Design:
When Microprocessors Aren’t Good Enough
Q: How long for each
• With microprocessors so easy, cheap, Image Sensor Micro- implementation option?
processor
and available, why design a digital (Read,
(a) 5+8+1
circuit? Memory
Compress,
and Store) =14 sec
• Microprocessor may be too slow
• Or too big, power hungry, or costly Image Sensor Read Compress
circuit circuit
.1+.5+.8
Sample digital camera task execution times (in seconds) (b) =1.4 sec
on a microprocessor versus a digital circuit: Store a
Memory
circuit
Task Microprocessor Custom Digital
Circuit Image Sensor Read Compress
circuit circuit
Read 5 0.1 .1+.5+1
Compress 8 0.5 (c) =1.6 sec
Microprocessor
Memory (Store)
Store 1 0.8 Good
compromise
24 © 2020 Arm Limited
24
Options for building embedded systems
Implementation Design Unit Upgrades Size Weight Power System
Cost Cost & Bug Speed
Fixes
Discrete Logic low medium difficult large high ? very fast
ASIC high very low difficult very small very low low extremely fast
Dedicated
Hardware
($500K/
mask set)
Programmable logic: low to medium easy small low medium to very fast
FPGA, PLD medium high
Software Running on
Microprocessor + low to medium easy small to low to medium moderate
Generic Hardware
memory + peripherals medium medium medium
MCU (int. memory & low low to easy small low medium slow to
peripherals) medium moderate
Embedded PC low high easy medium medium to medium to fast
high high
25 © 2020 Arm Limited
Why we embed microprocessor in system? (here)
• Microprocessors are a very efficient way to implement digital systems:
• high-performance processors can execute several instructions per cycle
• CPUs are highly optimized for speed by the latest manufacturing technology
• A microprocessor, on the other hand, can be used for many different algorithms simply
by changing the program it executes.
• Implementation of your application is faster than designing your own custom logic
• Microprocessors are flexible thank to their programmability:
• it is easier to design families of products
• it is easier to provide new features to keep up with rapidly changing markets
• it is possible to reuse software for next-generation products, thereby reducing
development time and cost.
26 © 2020 Arm Limited
Benefits of microcontroller-based embedded systems
Greater flexibility and Lower cost More features Better
efficiency dependability
More sophisticated Cheaper components Many not possible or Adaptive systems that can
control through software Reduced manufacturing costs impractical using other compensate for failures
approaches Better diagnostics to
Reduced operating and
maintenance costs improve repair time
27 © 2020 Arm Limited
Functions of embedded systems
Closed-loop control system
Monitor a process, adjust an output to maintain the desired set point of operation
(temperature, speed, direction, etc.)
Sequencing
Step through different stages based on environment and system conditions
Signal processing
Remove noise, select desired signal features
Communications and networking
Exchange information reliably and quickly
28 © 2020 Arm Limited
Attributes of embedded systems
Interfacing with larger systems/ Concurrent, reactive behaviors
environment
• Analog signals for reading sensors • Must respond to sequences and combinations of
• Use voltage to represent a physical value events
• Power electronics for driving motors and • Real-time systems have deadlines on responses
solenoids • Typically must perform multiple separate
• Digital interfaces for communicating with other activities concurrently
digital devices: UART, I2C, SPI, …
• User interfaces:
• Simple: switches, LEDs
• Complex: displays
29 © 2020 Arm Limited
Attributes of embedded systems
Fault handling Diagnostics
• Many systems must operate independently for
long periods of time that requires them to • Help systems developer and service personnel
handle likely faults without crashing determine problems quickly
• Often, the fault-handling code is larger and
more complex than the normal-case code
30 © 2020 Arm Limited
Constraints specific to embedded devices
Cost Size and weight Power and energy Environment
limits limits
Competitive markets penalize Mobile (aviation, Temperatures may range
products that do not deliver automotive) and portable Battery capacity, from -40 degrees C to 125
adequate value for money (e.g., handheld, wearable) cooling limits degrees C, or even more.
systems
31 © 2020 Arm Limited
The impact of constraints
MCUs used (rather than Programming language Operating system (OS)
microprocessors)
• Include peripherals to • Programmed in C rather than • Typically no OS, but instead
interface with other devices in Java that results in smaller simple scheduler, or even just
and respond efficiently and faster code, so less interrupts + main code
• On-chip RAM and ROM expensive MCU (foreground/background
reduce circuit board • Some performance-critical system)
complexity and cost code may be written in • If OS used, likely to be a lean
Assembly (a lower-level real-time one (RTOS).
language)
32 © 2020 Arm Limited
Embedded software
Software incorporated into/aiming to control machines or devices
• Usually specialized for a specific hardware platform
• Simple, limited memory requirements
• Often does not require OS support → firmware
• Subject to timing constraints
• Many control functions not tied to human interaction
33 © 2020 Arm Limited
Embedded software constraints
Lack of abstraction Responsiveness Concurrency
developer directly system needs to multiple physical
exposed to react to external events happening at
underlying triggers in a timely the same time must
hardware manner be handled
Efficiency Reliability
given energy & timing code errors can have
budgets, optimization catastrophic events
is required in practice
34 © 2020 Arm Limited
Embedded systems programming and debugging
Different option to upload/debug code on a microcontroller
• A range of interfaces are used to program embedded systems,
including Joint Test Action Group (JTAG), Serial Wire Debug
(SWD), Single Wire Interface Module (SWIM), etc.
• Programming consists of writing program code to non-volatile
memory (e.g., Electrically Erasable Programmable Read-Only
Memory (EEPROM)) and configuring the system via fuses.
• Configuration bits (fuses) control key behavior of embedded
hardware, e.g., clock rate, power-up timer, etc.
35 © 2020 Arm Limited
Embedded software debugging
Much more complicated than debugging regular software and involves some hardware interface
Challenging to debug code involving interactions with peripherals
Debug pins could be made available for programming and testing during manufacturing
Sometime convenient to implement a command-line interface (CLI) that can enable real-time
inspection of registers and memory contents
Integrated Development Environments (IDEs) frequently used to simplify debugging
36 © 2020 Arm Limited
Over-the-air programming
Sometimes possible for embedded devices equipped with a wireless interface
• Over-the-air (OTA) programming is particularly useful for
firmware updating after product release.
• A risk of rendering the device unusable exists, if programming is
interrupted or inappropriate software is uploaded → some
recovery mechanism should be implemented if OTA is desired.
• Ideally, a separate chip would handle OTA programming, but this
increases the footprint and cost of the device.
• More often, memory is reserved for a bootloader that handles
the OTA programming and, in case of update failure, this can
revert the application to the previous version.
37 © 2020 Arm Limited
Coming next
Module Contents
Hardware Platforms for IoT • What is a hardware platform
• Types of memory
• Power saving techniques
• Types of sensors
The Arm Cortex-M4 • Processors vs. architectures
Processor Architecture • Cortex-M4 features
• Cortex-M4 registers
Interrupts and Low Power • What are interrupts
Features • Exception handlers
• Timing analysis
• Program design with interrupts
38 © 2020 Arm Limited