Professional Documents
Culture Documents
2021 CoE2DX4 W0
2021 CoE2DX4 W0
2021 CoE2DX4 W0
Engineering
2DX4
Embedded Architecture &
The Cortex-M4
Week 0
mcmaster.ca |
Welcome to 2DX4
https://starwarsintrocreator.kassellabs.io/
mcmaster.ca | 2
Instructors
mcmaster.ca | 3
How Does This “Simple” Droid Work?
Specifically, from a Computer Engineer’s point of view, discuss how this system:
• Observes the world around it?
• Makes decisions?
• Actuates commands?
mcmaster.ca | 4
How Does Weather Information Get Collected?
The following map from www.wunderground.com has Hamilton and surrounding area weather
information provided in real-time (temperature, wind direction, and air quality shown). How is this
accomplished?
https://www.wunderground.com/
mcmaster.ca | 5
What Makes a System “Intelligent”?
Architecture vs. Characteristics
• Embedded micro systems have traditionally been taught from the perspective of the
computer architecture and their intelligent nature was derived from those capabilities.
• 2DX4 has been structured to teach the course content from the perspective of what makes
an embedded computing system intelligent.
• An intelligent micro system has three properties:
o Observe – an intelligent system can observe the world around it.
o Reason – an intelligent system can make decisions based upon the observed world
around it.
o Action – an intelligent system can interact with the world around it.
mcmaster.ca | 6
Introduction Observe
Week 3:
Week 0: Week 1: Week 2:
Timing, I/O, &
Embedded Systems & Signals Around Us Transduction & Analog
Structured Program
Architecture (Digital & Analog) Signal Acquisition
Organization
Reason
Course Organization Week 4:
Week 5: Week 6:
Act Overview
Week 7:
Week 8: Week A & B:
Week 9:
Event Based
Communication Embedded Systems &
Programming & Data Visualization
Protocols Architecture + Overview
Interrupts
mcmaster.ca | 7
Course Organization
2DX4 is structured into three core themes: Observe, Reason, and Act. Each theme
is stitched together with knowledge threads. The block flow diagram on the right
illustrates how each thread is structured.
Knowledge
Thread
Block Flow
Lab Prep
mcmaster.ca | 8
Introduction
The Texas Instrument
MSP-EXP432E401Y
LaunchPad
mcmaster.ca | 9
Course Materials
Please review carefully
Required:
Textbook: Valvano, “Embedded Systems: Introduction to ARM Cortex-M Microcontrollers”, 5th edition, 6th printing,
January 2019. Please note the edition, printing, and date! (A Kindle* digital version may be available via Amazon
– confirm version before purchase)
Hardware: A course hardware kit will be required. Information about the kit and purchase procedure will be
available on Avenue.
Software: A free Integrated Development Environment (IDE) will be used for this course. Refer to the course
website for information on obtaining the software.
Optional:
Textbook: Valvano, “Embedded Systems: Real-Time Interfacing to ARM Cortex-M Microcontrollers”, 5th edition,
6th printing, December 2017. Please note the edition, printing, and date! (A Kindle digital version may be
available via Amazon – confirm version before purchase)
*Kindle does not require a hardware
reader. Kindle documents can be
Calculator: None required. Not permitted on exams. read using free software and/or
online.
mcmaster.ca | 10
Frequently Asked Questions
Answers to common questions at the beginning of 2DX4
mcmaster.ca | 11
Frequently Asked Questions (cont.)
• I previously failed 2DP4, can I be exempt from project? No. See your
instructor ASAP to ensure you’re enrolled in correct course.
• I took 2DI4 x-years ago, do I really need to know it? Yes. 2DX4 assumes you
have a good understanding of logic and its application. Review your notes for
combinational and sequential logic, in additional to register transfer level
design/programming.
• I would like to speak with you in person, how can I schedule that? Please
see the Avenue for office hours.
• To which instructor do I submit MSAFs? Please submit to Dr. Shirani.
• Conflicts/permissions? Please submit to Dr. Shirani.
mcmaster.ca | 12
Microcontroller vs Microprocessor
mcmaster.ca | 13
•Broadcom BCM2711, Quad core Cortex-A72
The Raspberry Pi 4 (ARM v8) 64-bit SoC @ 1.5GHz
•1GB, 2GB or 4GB LPDDR4-3200 SDRAM
(depending on model)
•2.4 GHz and 5.0 GHz IEEE 802.11ac wireless,
Bluetooth 5.0, BLE
•Gigabit Ethernet
•2 USB 3.0 ports; 2 USB 2.0 ports.
•Raspberry Pi standard 40 pin GPIO header (fully
backwards compatible with previous boards)
•2 × micro-HDMI ports (up to 4kp60 supported)
•2-lane MIPI DSI display port
•2-lane MIPI CSI camera port
•4-pole stereo audio and composite video port
•H.265 (4kp60 decode), H264 (1080p60 decode,
1080p30 encode)
•OpenGL ES 3.0 graphics
•Micro-SD card slot for loading operating system
and data storage
•5V DC via USB-C connector (minimum 3A*)
•5V DC via GPIO header (minimum 3A*)
•Power over Ethernet (PoE) enabled (requires
separate PoE HAT)
•Operating temperature: 0 – 50 degrees C
ambient
A good quality 2.5A power supply can be used if
downstream USB peripherals consume less than
500mA in total.
https://www.raspberrypi.org/products/raspberry-pi-4-model-
b/specifications/
mcmaster.ca | 14
Computer Families
• The 8048/8051 microcontroller (Intel originally, but now made by many others such as Philips,
Dallas Semiconductor, Siemens, Atmel, Motorola)
• Motorola (now Freescale, now NXP) 6800-based microprocessor and the 68HC11 microcontroller,
plus newer derivatives such as the S12.
• Microchip PIC16/18/24
• Soft processors (embedded into FPGAs and ASICs such as Altera NIOS II and Xilinx MicroBlaze)
mcmaster.ca | 15
Milestones in Micro Architecture
mcmaster.ca | 16
Milestones in Micro Architecture
mcmaster.ca | 17
What is a Computer?
?
mcmaster.ca | 18
What is a Computer?
Hardware
? Software
mcmaster.ca | 19
To avoid unnecessary complexities at
The von Neumann this stage, we will use this model to
This is how most modern computing systems are structured. represent our micro to simplify
discussion. For those that are
interested to know the differences,
look ahead to the textbook section 3.4.
mcmaster.ca | 20
The von Neumann
This is how most modern computing systems are structured.
• Processor consists of the arithmetic logic unit (ALU), control unit, and registers.
o The ALU handles arithmetic and logic operations
o The Control Unit is the processor’s traffic controller, it decodes and handles machine code and performs the operations
specified
o The Registers are storage locations inside the CPU that are used to hold data or address during the execution of an
instruction.
• Common Bus interfaces between the processor and digital units or peripherals (example, Memory, I/O)
• A microcontroller incorporates the processor and one or more of the following:
o Memory
o Timer functions
o Communication functions
o ADC
o DAC
o Direct Memory Access
o I/O ports
o Software Debug support
mcmaster.ca | 21
Nomenclature
mcmaster.ca | 22
The ENIAC
mcmaster.ca | 23
Hardwired vs. “Softwired”
✤ Hardwired ✤ “Softwired”
Data Input Memory Instructions in
A-F Memory
A Send to X
Output from
Computer with
B Send to X stored instructions
C Send to X X
D Send to Y Y
E Send to Y
F Send to Y
X =A+ B + C X =A+ B + C
Y=D+E+F Y=D+E+F
mcmaster.ca | 24
Memory
The two elements of every memory cell:
address contents
• Computer memory is comparable to 0 LDA 14
a collection of mailboxes. 1 ADD 15
2 STA 14
• Each memory cell has two 3 HLT
components: 4 153
5 'A'
o its address, and 6 6.5
8 gray pixel
never empty.
10 0
11 0
13 0
(RAM) 14 10
15 7
• Volatile memory …
mcmaster.ca | 25
Memory continued
mcmaster.ca | 26
Talk To The Machine
• Compiler?
• Interpreter?
mcmaster.ca | 27
Talk To The Machine
• Compiler?
• Interpreter?
} Yes, but these are for us
mcmaster.ca | 28
Talk To The Machine
• Compiler?
• Interpreter?
} Yes, but these are for us
010101010101010101101000101010101
mcmaster.ca | 29
How a Basic Computer Works
mcmaster.ca | 30
How a Basic Computer Works (cont’d)
For each basic command, an operation code is required.
mcmaster.ca | 31
How a Basic Computer Works (cont’d)
Using our operation codes, if we wanted to write a program using our Basic
Computer it would resemble:
0000 Start
0011 1110 Load 14
0010 1111 Add 15
0100 1110 Save 14
Stop
0001
Hard to understand, enter, debug, and maintain for human being
mcmaster.ca | 32
How a Basic Computer Works (cont’d)
• The usage of operation code (op-codes) is not human friendly, but this is
the language the computer understands (machine language).
mcmaster.ca | 33
How a Basic Computer Works (cont’d)
For each basic command, an operation code is required and a mnemonic
mcmaster.ca | 34
CPU-Memory Interaction
0 LDA 14
a = a + b;
1 ADD 15
2 STA 14
3 HLT
Before After
… a 14 10 a 14 17
14 10
15 7 b 15 7 b 15 7
mcmaster.ca | 35
Assembly Language
• Defined by assembler instructions
The two elements of every memory cell:
1 ADD 15
• Assembly programs must me translated into
2 STA 14
machine language before it can be executed.
3 HLT
15 7
mcmaster.ca | 36
Example Assembly Code
RO,R0,#25 I 7) .
Ox000001C2 6008 STR rO, [rl, #OxOO] STR RO, [Rl] 8) .
Ox000001C4 4770 BX lr BX LR I
I
9) .
Ox000001C6 4903 LOR rl, [pc, #12] Start LOR Rl,=Num ; 1)
Ox000001C8 F04FOOOO MOV rO,#OxOO MOV R0,#0 I 2) .
OxOOOOOlCC 6008 STR rO, [rl,#OxOO] STR RO, [Rl] ; 3)
OxOOOOOlCE F7FFFFF4 BL.W OxOOOOOlBA loop BL Change 4) .
Ox000001D2 E7FC B OxOOOOOlCE B loop
I
I 10) .
Ox000001D4 20000000
Program 3.15. Assemb!J version of Program 3.9. The 1-2-... -10 show the execution sequence.to ARM Cortex-M Microcontrollers”, 6ed., 2019
Valvano, “Introduction
R/W mcmaster.ca
Address
- -
Data Operations | 37
Instruction
Example Assembly Code 1
Source Code
3 2 AREA DATA, ALIGN=2
Num SPACE 4
AREA CODE,READONLY,ALIGN=2
Machine Code Assembly Code THUMB
EXPORT Start
Ox0000f.\1.13A 4906 LOR rl, [pc, #24] Change LOR Rl,=Num ; 5)
OxOOOOOlBC 6808 LOR rO, [rl,#OxOO] LOR RO, [Rl] 6) .
OxOOOOOlBE F1000019 ADD r0,r0,#0x19 ADD
I
RO,R0,#25 I 7) .
Ox000001C2 6008 STR rO, [rl, #OxOO] STR RO, [Rl] 8) .
Ox000001C4 4770 BX lr BX LR I
I
9) .
Ox000001C6 4903 LOR rl, [pc, #12] Start LOR Rl,=Num ; 1)
Ox000001C8 F04FOOOO MOV rO,#OxOO MOV R0,#0 I 2) .
OxOOOOOlCC 6008 STR rO, [rl,#OxOO] STR RO, [Rl] ; 3)
OxOOOOOlCE F7FFFFF4 BL.W OxOOOOOlBA loop BL Change 4) .
Ox000001D2 E7FC B OxOOOOOlCE B loop
I
I 10) .
Ox000001D4 20000000 This is the program you write
Program
This3.15. Assemb!J
is the programversion of Program
translated to3.9. The 1-2-... -10 show the execution
assembler sequence.to ARM Cortex-M Microcontrollers”, 6ed., 2019
Valvano, “Introduction
mcmaster.ca | 39
Memory System
mcmaster.ca | 40
Memory System
mcmaster.ca | 41
Program Execution
• How does the micro know where the program should execute?
mcmaster.ca | 42
Program Execution
• How does the micro know where the program should execute?
A circuit referred to as the Program Counter (PC) provides a
pointer the next instruction to be fetched/executed.
mcmaster.ca | 43
Organization of
the Cortex-M4
Micro
High Level Block Diagram:
Processor
mcmaster.ca | 44
Organization of
the Cortex-M4
Micro
High Level Block Diagram:
System Peripherals
mcmaster.ca | 45
Organization of
the Cortex-M4
Micro
High Level Block Diagram:
Serial, Analog, & Motion
Peripherals
mcmaster.ca | 46
2DI4 Recall:
Cortex-M4 Registers What is a register?
• Special-purpose Program
Status Registers, (xPSR).
mcmaster.ca | 47
Cortex-M4 Registers
The general-purpose registers r0-r12 have no special architecturally-defined uses. Most
instructions that can specify a general-purpose register can specify r0-r12.
Low registers Registers r0-r7 are accessible by all instructions that specify a general-purpose
register.
High registers Registers r8-r12 are accessible by all 32-bit instructions that specify a general-
purpose register. Registers r8-r12 are not accessible by all 16-bit instructions.
Registers r13, r14, and r15 have the following special functions:
• Stack pointer Register r13 is used as the Stack Pointer (SP).
• Link register Register r14 is the subroutine Link Register (LR).
• Program counter Register r15 is the Program Counter (PC).
mcmaster.ca | 48
Looking Forward
o Introduction
o Simple I/O
mcmaster.ca | 49