Professional Documents
Culture Documents
IIIT Chittor
September 3, 2016
1 / 115
Course Contents
I Introduction to Embedded Systems.
I Characteristics, Different Types of Embedded Systems,
Components of Embedded System,
I Hardware Architecture, Processor, Peripheral Devices,
Embedded Software Architecture, Need of Real Time
Operating Systems and Different Application Areas.
I Processor and Memory Selection: Different Types of Processor
Technologies, Processor Selection for an Embedded System,
Different Types of Memory Devices, Memory Selection for an
Embedded System.
I Interfacing
I Communication protocol concepts, Microprocessor interfacing:
I/O addressing, Port and Bus based, I/O, Memory Mapped
I/O, Standard I/O interrupts, Direct memory access, Serial
Communication Protocols I2C
I CAN, Parallel Communication Protocols PCI bus, Wireless
protocol Bluetooth etc.
I Different types of Interrupts, Interrupt Servicing Mechanism,
Device Servicing using ISR
2 / 115
Contents....
3 / 115
Preferred Textbooks and References
4 / 115
Week wise Syllabus Coverage
6 / 115
Harware Kits for Course Project
(a)
(b) (c)
(a)
(b)
9 / 115
Embedded Systems Examples
10 / 115
Definitions
11 / 115
Embedded Systems: Part of Evolving Research Areas
(a) (b)
(c) (d)
12 / 115
Desktop Vs Embedded Computer
13 / 115
Desktop Vs Embedded Computer ...
(a) (b)
14 / 115
lets Talk about your Favourite Gadzet - Mobile Phone
Basic functionality of Mobile ?
I To Communicate (Voice)
I Display
I Input Keys
(a) (b)
15 / 115
Different Components of Embedded Systems
I Microprocessor
I Memory
I Input, Output and Other Interfaces
I Software
16 / 115
Design Metrics for Embedded System
17 / 115
Different Types of Embedded Systems
18 / 115
Top Down Approach
19 / 115
Case Study: GPS based Road Navigation System
Requirements
I Name: GPS moving map
I Purpose: Consumer-grade moving map for driving use
I Inputs: Power button, two control buttons
I Outputs: Back-lit LCD display 400X600
I Functions: Uses 5-receiver GPS system; three user-selectable
resolutions; always displays current latitude and longitude
I Performance: Updates screen within 0.25 seconds upon
movement
I Manufacturing cost: 2100 Rs Power 100mW Physical size and
weight No more than 2X6 inch, 12 ounces
20 / 115
Case Study: GPS based Road Navigation System
Specifications
I Data received from the GPS satellite constellation.
I Map data.
I User interface.
I Operations that must be performed to satisfy customer
requests.
I Background actions required to keep the system running, such
as operating the GPS receiver.
21 / 115
Architecture: Block Diagram of GPS based Road
Navigation System
(a)
22 / 115
Architecture of GPS Navigation - Hardware
(a)
23 / 115
Architecture of GPS Navigation - Software
(a)
24 / 115
Components and System Integration stages of GPS
Navigation module
Components Design:
I Both Hardware and Software modules design
I Hardware: FPGA, standard Integrated Circuits, DSP, PCB
I Software: Topographical Database, Algorithms
I Hardware and Software Co-design
System Integration:
I Integration of all subsystems
I Debugging
I Correctness
25 / 115
General Purpose MicroProcessor and Microcontroller
26 / 115
Microcontroller
I integrating number of components and a Microprocessor onto
a single chip
I less computational specific microprocessor, memory, serial and
parallel Input/ouput, Application specific
Figure: Microcontroller
27 / 115
Components of a Microcontroller
Figure: Microcontroller
28 / 115
Microcontroller Vs Microprocessor for Embedded
applications
29 / 115
Computer Architectures
30 / 115
Von Neumann architecture
Single Bus for Instructions and Data
I Bit widths should be same for Instruction and Data
I Data Transfers and Instructions fetches should be Scheduled
I Pipelining is complex
I Early Systems
31 / 115
Harvard Architecture
Seperate instruction and Data buses
I Different Widths can be different for Data and Instruction
I Simultaneous and faster operation
I Pipelining is Easier than Von Nuemann
I Most of the Modern Systems
I Examples: DSP processors, ARM, AVR, ATMEL, PIC etc.
32 / 115
ARM Family
33 / 115
Memory
34 / 115
Memory
35 / 115
Memory
36 / 115
Word
37 / 115
ROM
I Mask programmed ROM
I ONe Time Programmable ROM
I Erasable Programmabel ROM
I Electrically Erasable Programable ROM
I FLASH
38 / 115
RAM
I Static RAM - Flipflops
I Dynamic RAM - MOS transistor with capacitor
I PSRAM - Pseudo Static RAM: DRAM with built in memory
refresh controller
I Non Volatile RAM - Battery backed RAM
SRAM with a battery
SRAM with EEPROM can completely store RAM contents on
EEPROM or FLASH
39 / 115
Extending Memory - Number of words/width of words
40 / 115
Extending Memory - both for Number of words and width
of words
41 / 115
CY8CKIT59
42 / 115
General Purpose Input Output
43 / 115
CY8CKIT59 - GPIO
44 / 115
Analog to Digital Converter - ADC
I Direct/Flash ADC
I Successive Approximation ADC
I Dual Slope ADC
I Sigma Delta ADC
Reading Assignment: Dual Slope and Sigma Delta ADC
45 / 115
Flash ADC
46 / 115
Successive Approximation ADC
47 / 115
Successive Approximation ADC
48 / 115
Multi Channel ADC
49 / 115
Introduction to ARM Cortex M3
50 / 115
Different Profiles of ARM v7
51 / 115
Introduction to ARM Cortex M3
52 / 115
Different ARM Processors and their features
53 / 115
Different ARM Processors and their features
54 / 115
Cotex M3 Applications
I Low-cost microcontrollers
I Automotive
I Data communications
I Industrial controller
I Consumer products
55 / 115
ARM Cortex M3 - Simplified Archtecture
56 / 115
ARM Cortex M3 - Registers
57 / 115
ARM Cortex M3 - Special Registers
58 / 115
ARM Cortex M3 - Operation modes
59 / 115
ARM Cortex M3 - Interrupt Controller Features
60 / 115
ARM Cortex M3 - Memory MAP
61 / 115
ARM Cortex M3 - Memory Map
62 / 115
ARM Cortex M3 - BUS interface
63 / 115
ARM Cortex M3 - Memory Protection Unit (MPU)
I Optional MPU
I Rules for priviliged access and user program access
I If a rule is voilated fault exception is generated and fault exception handler will
be able to analyze the problem and correct it.
I To protect OS kernel and other previliged process from untrusted programs.
I To prevent accidental erase of data when multi-tasking by isolating memory
regions.
64 / 115
ARM Cortex M3 - Instruction Set
I No state switching overhead, saving both execution time and instruction space
I No need to separate ARM code and Thumb code source files, making software
development and maintenance easier
I It is easier to get the best efficiency and performance, in turn making it easier to
write software, because there is no need to worry about switching code between
ARM and Thumb to try to get the best density/performance
65 / 115
ARM Cortex M3 - Instruction Set
I UFBX, BFI, and BFC: Bit field extract, insert, and clear instructions
I UDIV and SDIV: Unsigned and signed divide instructions
I WFE, WFI, and SEV: Wait-For-Event, Wait-For-Interrupts, and Send-Event to
handle task synchronization on multiprocessor systems
I MSR and MRS: Move to special register from general-purpose register and
move special register to general-purpose register
66 / 115
ARM Cortex M3 - Low Power and High Energy Efficiency
I sleep mode and deep sleep mode supports to reduce power consumption during
idle period
I low gate count and design techniques reduce circuit activities
I Due to high code density, program size is reduced which will reduce active time
and reduce energy
I Wake-up Interrupt Controller to power down, while processor states are retained
and can be active with a simple wake-up call.
67 / 115
ARM Cortex M3 - Debug Support
68 / 115
ARM Cortex M3 - Registers
69 / 115
ARM Cortex M3 - Registers - Stack Pointer R13
70 / 115
Registers - Link Register R14, Program Counter R15,
Special Registers
I R14 - used to store the return program counter (PC) when a subroutine or
function is called
I R15 - is a processor register that indicates where a computer is in its program
sequence
I PC is incremented after fetching an instruction, and holds the memory address
of the next instruction that would be executed
Special Registers
I Program Status registers (PSRs)
I Interrupt Mask registers (PRIMASK, FAULTMASK, and BASEPRI)
I Control register (CONTROL)
71 / 115
Registers - Program Status Registers
I Application Program Status register (APSR)
I Interrupt Program Status register (IPSR)
I Execution Program Status register (EPSR)
72 / 115
Registers - Program Status Registers
73 / 115
Interrupt Mask registers and Control Registers
I PRIMASK: 1-bit register.
it allows nonmaskable interrupt (NMI) and the hard fault exception. all other
interrupts and exceptions are masked
I FAULTMASK: A 1-bit register
it allows only the NMI, and all interrupts and fault handling exceptions are
disabled
I BASEPRI: A register of up to 8 bits
it disables all interrupts of the same or lower level (larger priority value). Higher
priority interrupts can still be allowed
Control RegisterThe control register is used to define the privilege level and the SP
selection. This register has 2 bits
74 / 115
Processor Modes and Privilages
75 / 115
Processor Modes and Privilages
76 / 115
Processor Modes and Privilages
77 / 115
Processor Modes and Privilages
78 / 115
Dual Stack Implementation
79 / 115
Dual Stack Implementation
80 / 115
Differentiating 16 bit Thumb and 32 bit Thumb-2
instruction bits
1. ADDS R0, #1 Use 16-bit Thumb instruction by default; for smaller size
2. ADDS.N R0, #1 Use 16-bit Thumb instruction (N=Narrow)
3. ADDS.W R0, #1 Use 32-bit Thumb-2 instruction (W=wide)
81 / 115
16 bit Instruction Set
I ADC Add with carry
I ADD Add
I ADR Add PC and an immediate value and put the result in a register
I AND Logical AND
I ASR Arithmetic shift right
I BIC Bit clear (Logical AND one value with the logic inversion of another value)
I CMN Compare negative (compare one data with 2s complement of another
data and update flags)
I CMP Compare (compare two data and update flags)
I CPY Copy (available from architecture v6; move a value from one high or low
register to another high or low register); synonym of MOV instruction
I EOR Exclusive OR
I LSL Logical shift left
I LSR Logical shift right
I MOV Move (can be used for register-to-register transfers or loading immediate
data)
I MUL Multiply
I MVN Move NOT (obtain logical inverted value)
I NEG Negate (obtain twos complement value), equivalent to RSB
82 / 115
Exceptions
83 / 115
System Exceptions
84 / 115
System Exceptions and Priority
85 / 115
System Exceptions and Priority
86 / 115
System Exceptions and Priority
87 / 115
Sub Priorities
88 / 115
Vector Tables
89 / 115
Interrupt Pending
90 / 115
Interrupt Pending
91 / 115
Fault Exceptions
I Bus faults
I Memory management faults
I Usage faults
I Hard faults
92 / 115
BUS Fault Exceptions
93 / 115
Memory Management and Usage Faults
Usage Faults
I Undefined instructions
I Coprocessor instructions (the Cortex-M3 processor does not support a
coprocessor, but it is possible to use the fault exception mechanism to run
software compiled for other Cortex processors through coprocessor emulation)
I Trying to switch to the ARM state (software can use this faulting mechanism to
test whether the processor it is running on supports the ARM code; because the
Cortex-M3 does not support the ARM state, a usage fault takes place if theres
an attempt to switch)
I Invalid interrupt return (link register contains invalid/incorrect values)
I Unaligned memory accesses using multiple load or store instructions
94 / 115
Hard Faults
The hard fault handler can be caused by usage faults, bus faults,
and memory management faults cannot be executed.
I it can due to bus fault during vector fetch (reading of a vector
table during exception handling).
I In the NVIC, Fault Status Register (FSR) is used to know
whether the fault was caused by a vector fetch. else it need to
check the other FSRs to determine the cause of the hard fault.
95 / 115
Tail-Chaining Interrupts
96 / 115
Late Arrivals - Interrupts
97 / 115
Interrupt Latency
The delay from the start of the interrupt request to the start of
interrupt handler execution
I if the memory system has zero latency, and provided that the
bus system design allows vector fetch and stacking to happen
at the same time, the interrupt latency can be as low as 12
cycles
I includes stacking the registers, vector fetch, and fetching
instructions for the interrupt handler.
I Tail-chaining interrupts ?
I executing a multicycle instruction
I the Cortex-M3 processor allows exceptions in the middle of
Multiple Load and Store instructions
98 / 115
ARM Instruction Pipeline
99 / 115
ARM Instruction Pipeline
100 / 115
ARM Instruction Pipeline
101 / 115
ARM Instruction Pipeline
102 / 115
Architecture and Interfacing in Cortex M3
103 / 115