Professional Documents
Culture Documents
EEE415 Week08 Embedded Systems
EEE415 Week08 Embedded Systems
EEE Introduction to
Embedded Systems Design
• Lower power
1
DRAFT 7/21/2023
Register banks
ALU
Microprocessor
System Bus
Microcontroller
2
DRAFT 7/21/2023
Source: https://developer.arm.com/ip-products/subsystem/corstone-foundation-ip/cortex-m-system-design-kit
Dr. Sajid Muhaimin Choudhury 7
EEE 415 - Department of EEE, BUET Internet, ARM Educatoin © 2022
Embedded
System
3
DRAFT 7/21/2023
• More features
• Many not possible or practical with other approaches
• Better dependability
• Adaptive system which can compensate for failures
• Better diagnostics to improve repair time
• Fault handling
• Many systems must operate independently for long periods of time, requiring
system to handle likely faults without crashing
• Often fault-handling code is larger and more complex than normal-case code
• Diagnostics
• Help service personnel determine problem quickly
10
4
DRAFT 7/21/2023
Input:
Inputs: Wheel rotation
Functions:
- Wheel rotation indicator Mode key
- Speed measurement
- Mode key
- Distance measurement
Output:
Constraints: - Liquid crystal display
- Size
- Cost Use low-performance
- Power and energy microcontroller: Output:
- 9-bit, 10 MIPS Display speed and
- Weight distance
11
Constraints:
Use high-performance
- Reliability in harsh microcontroller:
environment
- E.g. 32-bit, 3 MB flash
- Cost memory, 50-300 MHz
- Size
12
5
DRAFT 7/21/2023
13
• Energy harvesting
14
6
DRAFT 7/21/2023
15
Programmable low to mid mid easy small low medium to high very fast
Microprocessor + low to mid mid easy small to medium low to moderate medium moderate
Software Running on
memory +
Generic Hardware
peripherals
Microcontroller low mid to low easy small low medium slow to moderate
Embedded PC low high easy medium moderate to high medium to high fast
16
7
DRAFT 7/21/2023
• Environment
• Temperatures may range from -40°C to 125°C, or even more
Dr. Sajid Muhaimin Choudhury 17
EEE 415 - Department of EEE, BUET Internet, ARM Educatoin © 2022
17
Impact of Constraints
• Microcontrollers used (rather than microprocessors)
• Include peripherals to interface with other devices, respond efficiently
• On-chip RAM, ROM reduce circuit board complexity and cost
• Programming language
• Programmed in C rather than Java (smaller and faster code, so less expensive
MCU)
• Some performance-critical code may be in assembly language
• Operating system
• Typically no OS, but instead simple scheduler (or even just interrupts + main
code (foreground/background system)
• If OS is used, likely to be a lean RTOS
18
8
DRAFT 7/21/2023
19
Impact of Constraints
• Microcontrollers used (rather than microprocessors)
• Include peripherals to interface with other devices, respond efficiently
• On-chip RAM, ROM reduce circuit board complexity and cost
• Programming language
• Programmed in the C language rather than Java (resulting in smaller and faster code – less
expensive MCU)
• Some performance-critical code may be in assembly language
• Operating system
• Typically no OS, but instead a simple scheduler
• If OS is used, it is likely to be a lean RTOS
20
9
DRAFT 7/21/2023
21
22
10
DRAFT 7/21/2023
• Arm
• The company that designs Arm-based processors
• Arm does not manufacture, but it licenses designs to semiconductor partners who add their own
intellectual property (IP) on top of Arm’s OP, which they then fabricate and sell to customers
• Arm also offers IP other than processors, such as physical IPs, interconnect IPs, graphics cores and
development tools
23
Arm7
• Earlier classic processors including Arm7, Arm9, Arm11 families Classic Arm9
Arm11
24
11
DRAFT 7/21/2023
• Smaller code
• Lower silicon costs
• Ease of use
• Faster software development and reuse
• Embedded applications
• Smart metering, human interface devices, automotive and industrial control systems, white
goods, consumer products and medical instrumentation
25
IP libraries SoC
Cortex-A9 Cortex-R5 Cortex-M4 Arm
ROM RAM
processor
Arm7 Arm9 Arm11
System bus Arm-based
DRAM ctrl FLASH ctrl SRAM ctrl SoC
Peripherals
AXI bus AHB bus APB bus
26
12
DRAFT 7/21/2023
27
Cortex-M4 ARMv7E-M Harvard Entire Entire 1 cycle Yes Yes Hardware Optional
28
13
DRAFT 7/21/2023
29
30
14
DRAFT 7/21/2023
31
32
15
DRAFT 7/21/2023
Wake-up
Interrupt
Controller
Memory
(WIC) Flash Data
Protection
Patch Unit (MPU)
Watchpoint
33
Time
Dr. Sajid Muhaimin Choudhury 34
EEE 415 - Department of EEE, BUET Internet, ARM Educatoin © 2022
34
16
DRAFT 7/21/2023
35
• Debug subsystem
• Handles debug control, program breakpoints, and data watchpoints
• When a debug event occurs, it can put the processor core in a halted state, so developers can
analyse the status of the processor, such as register values and flags, at that point
36
17
DRAFT 7/21/2023
• Cortex-M4 registers
• Register bank
Sixteen 32-bit registers (thirteen are used for general-purpose);
• Special registers
37
Cortex-M4 Registers
• APSR
• N: negative flag – set to one if the result from ALU is negative
• Z: zero flag – set to one if the result from ALU is zero
• C: carry flag – set to one if an unsigned overflow occurs
• V: overflow flag – set to one if a signed overflow occurs
• Q: sticky saturation flag – set to one if saturation has occurred in saturating arithmetic
instructions, or overflow has occurred in certain multiply instructions
• IPSR
• ISR number – current executing interrupt service routine number
• EPSR
• T: Thumb state – always one since Cortex-M4 only supports the Thumb state (more on
processor states in the next module)
• IC/IT: Interrupt-Continuable Instruction (ICI) bit, IF-THEN instruction status bit
38
18
DRAFT 7/21/2023
Cortex-M4 Registers
• Interrupt mask registers
• 1-bit PRIMASK
Set to one will block all the interrupts apart from nonmaskable interrupt (NMI) and the hard fault exception
• 1-bit FAULTMASK
Set to one will block all the interrupts apart from NMI
• 1-bit BASEPRI
Set to one will block all interrupts of the same or lower level (only allow for interrupts with higher priorities)
39
Cortex-M4 Registers
PRIMASK
PRIMASK Reserved
FAULTMASK
FAULTMASK Reserved
BASEPRI
BASEPRI Reserved
CONTROL Reserved
40
19
DRAFT 7/21/2023
41
42
20
DRAFT 7/21/2023
43
44
21
DRAFT 7/21/2023
45
AHB bus
External SRAM,
External LCD SD card
FLASH
46
22
DRAFT 7/21/2023
Code region
External Interrupts
SysTick
PendSV
Reserved
Start-up routine & Debug monitor
Program code & SVCall
C library code Reserved
Program
Image Usage fault
Bus fault
MemManage fault
Hard fault vector
NMI vector
Vector table Reset vector
0x00000000 Initial MSP value
Dr. Sajid Muhaimin Choudhury 47
EEE 415 - Department of EEE, BUET Internet, ARM Educatoin © 2022
47
• First
reads the initial MSP value; Fetch initial value for MSP
• Then reads the reset vector; (Read address 0x00000000)
48
23
DRAFT 7/21/2023
Cortex-M4 Endianness
• Endian refers to the order of bytes stored in memory
• Big endian: lowest byte of a word-size data is stored in bit 0 to bit 7
• Big endian: lowest byte of a word-size data is stored in bit 24 to bit 31
• Cortex-M4 supports both little endian and big endian
• However, Endianness only exists in the hardware level
49
50
24
DRAFT 7/21/2023
0
ARM
Incoming Instructions
Instruction
Instructions Executing
Thumb remap decoder
1
to ARM
T bit, 0: select ARM,
1: select Thumb
• Thumb-2 instruction set
• Consists of both 32-bit Thumb instructions and original 16-bit Thumb-1 instruction sets
• Compared to 32-bit ARM instructions set, code size is reduced by ~26%, while keeping a similar
performance
• Capable of handling all processing requirements in one operation state
51
52
25
DRAFT 7/21/2023
53
Useful Resources
• Architecture Reference Manual:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0403c/index.html
• Cortex-M4 Technical Reference Manual:
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0439d/DDI0439D_cortex_m4_processor_r0p1_trm.pdf
• Cortex-M4 Devices Generic User Guide:
http://infocenter.arm.com/help/topic/com.arm.doc.dui0553a/DUI0553A_cortex_m4_dgug.pdf
54
26
DRAFT 7/21/2023
55
• For example
…
ALIGN 4 ; Align to a word boundary
MY_DATA DCD 0x12345678 ; Insert a word-size data
MY_STRING DCB “Hello”, 0 ; Null terminated string
…
56
27