SlideShare a Scribd company logo
1 of 110
ARM Microcontroller and
Embedded Systems
Prof. Amogha B
Asst Prof.
Dept. of ECE
Visvesvaraya Technological University, Belagavi.
Jain Institute of Technology, Davangere.
(A Unit of Jain Group of Institutions, Bangalore)
Brief about subject
• Module 1-
• Module 2-
• Module 3-
• Module 4-
• Module 5-
C:UsersAmoghaDesktop15EC62.pdf
2Dept. of ECE, JIT, Davangere
Before entering the syllabus
• Shall see about the some of the basics
• A general Discussion
• IF X bits controller means what
– Microprocessor 64 bit
– Microcontroller 8 , 16, 32 bits
• Think
3Dept. of ECE, JIT, Davangere
ARM Microcontroller
• ARM founded in November 1990
– Advanced RISC Machines
– 32 bit Microcontroller
• Company headquarters in Cambridge, UK
– Processor design centers in Cambridge, Austin, and Sophia
Antipolis. (They won’t manufacture Micro-controllers)
– Sales, support, and engineering offices all over the world
• What RISC means- Reduced Instruction Set Computer
• What CISK means-
4Dept. of ECE, JIT, Davangere
RISK and CISC
CISC RISC
Full form Full form
Includes multi clock for complex instr. Single clock
Load and store is used for memory to
memory
Register to register
Small code size Large code size but time for execution
remains same
5Dept. of ECE, JIT, Davangere
ARM
• Assembly for arm we write only for
understanding the architecture.
– Beyond add/sub everything becomes complex and its
lost.
• ARM cortex are not mean for writing assembly
they actually not designed for it. Critically mean
for C
• With C coding it becomes more Powerful.
6Dept. of ECE, JIT, Davangere
1st Critical thinking of ARM developers
• They made 32 bit memory access
• During the launch of ARM all other companies
were on 16bit and almost all the instructions
are 16bit.
• Memory under utilization 60-70% hence
Thumb mode.
• ARM with pipelined makes 2 instructions to
run as 32bit which makes it faster.
7Dept. of ECE, JIT, Davangere
Thumb mode
• It became too much famous almost famous as
cortex all instructions executes at faster rate.
Problem of THUMB
• It doesn’t support all the instructions of ARM
• When thumb doesn’t supports it should
switch to ARM mode hence for switching it
became overhead.
8Dept. of ECE, JIT, Davangere
THUMB2
• To address this they have came up with hybrid
architecture it is called as thumb 2
• This architecture is not having switching issue
and it is in ARM-CORTEX series.
• Important for working it access 16 bit memory
and carries work or process in ARM
architecture.
9Dept. of ECE, JIT, Davangere
Graph
10Dept. of ECE, JIT, Davangere
Cortex has three division
• CORTEX A – application specific such as
OS(IOS, android or windows) mobile phones
applications.
• CORTEX M- Microcontroller a general purpose
widely used.
• CORTEX R- Real time applications in medical
and defense sectors.
– Hardware support ex: Controller supports adder
means ?????
11Dept. of ECE, JIT, Davangere
What ARM supplies and what partners
of ARM performs
12Dept. of ECE, JIT, Davangere
Architecture In detail (SEE IN NEXT
SLIDES)
AMBA – 1996
Advanced
Microcontroller
Bus Architecture
13Dept. of ECE, JIT, Davangere
Halfword and
signed halfword /
byte support
System mode
Thumb
instruction set
(v4T)
Improved
interworking
Saturated arithmetic
DSP MAC instructions
Extensions:
Jazelle (5TEJ)
SIMD Instructions
Multi-processing
v6 Memory architecture
Unaligned data support
Extensions:
Thumb-2 (6T2)
TrustZone® (6Z)
Multicore (6K)
Thumb only (6-M)
 Note that implementations of the same architecture can be different
 Cortex-A8 - architecture v7-A, with a 13-stage pipeline
 Cortex-A9 - architecture v7-A, with an 8-stage pipeline
Thumb-2
Architecture Profiles
7-A - Applications
7-R - Real-time
7-M - Microcontroller
v4 v5 v6 v7
Development of the ARM Architecture
14Dept. of ECE, JIT, Davangere
Nomenclature of ARM (Naming)
CRITICALLY Imp.
15Dept. of ECE, JIT, Davangere
Difference
• Simulation
– Ex: Dr driving game is a excellent example
• Emulation
– Games played at M2
• Some works in simulation but fails in real
world
• Which works in Emulation works everywhere.
• 8051 was not having EMULATOR/ ICE on
board.
16Dept. of ECE, JIT, Davangere
4 Critical Thinking made ARM to stand
1st
Why its called a wonderful architecture and it
proved to be same.
4. Interrupts nested ( upto 240).
17Dept. of ECE, JIT, Davangere
Oscillators
• Three oscillators
• External
• Internal
• RTC- Real Time Clock
18Dept. of ECE, JIT, Davangere
Interrupts
• What is interrupts?
• Ex:
19Dept. of ECE, JIT, Davangere
What is blue screen
• Hint : fatal error
20Dept. of ECE, JIT, Davangere
Exception
• Invalid behavior are identified by ARM and
provided to user.
21Dept. of ECE, JIT, Davangere
Which company focus on CISK
architecture
download.png
22Dept. of ECE, JIT, Davangere
Assembly program structure
• Area – directive which allocates the memory for
code and data
• Program name- it should be different for code
and data
• Entry – start of program
• Export label_name (practical)
• End- of program
• Important thing is have one endless loop in
embedded systems.
23Dept. of ECE, JIT, Davangere
Lets write some simple code
• For instance adding two number and store in
another register
• Mov r0, #5 ; it can access only registers not
memory
• ADD r0, r1, r2 ; r0 = r1 + r2
• Load instruction LDR
– Load to memory
– Pseudo information
• Store instruction STR
– Store from memory to register.
24Dept. of ECE, JIT, Davangere
Structure of C with ARM
• Include lpc17xx.h
• Global variables or define
• Int main()
• Main program
• To write code in any language we need to know
– Keyword
– Looping or syntax
– Logic ( Most Important)
25Dept. of ECE, JIT, Davangere
OUTLINE
• Thumb-2 technology and applications of ARM,
• Architecture of ARM Cortex M3,
• Various Units in the architecture, Debugging
support,
• General Purpose Registers, Special Registers,
exceptions, interrupts, stack operation, reset
sequence
26Dept. of ECE, JIT, Davangere
Introduction
27Dept. of ECE, JIT, Davangere
• The market of the microcontroller is vast every year 20 billions are
manufactured and they are released for sale.
• In the competitive world to meet the industrial demands the microcontrollers
should posses higher performance.
•Ex: Performing more work without increase in the clock frequency
•It should support communication peripherals such as USB, UART, Ethernet
etc.
•Enhance the user interface, multimedia requirements, system speed etc.
•In 2006 the ARM CORTEX family have entered into market
•Cortex M3 made a excellent performance with less gates (12,000) which
covers features of the previously launched high-end controllers.
Market demands for 32bit
Microcontroller
• Greater Performance Efficiency : with less power
and frequency should need more work
• Interrupt latency
• Improved code density
• Easy to use : migrating of programs from 8 to 32
bit
• Lower cost : less than a dollar
• Wide choice of development tools : companies
must posses evaluation and full version of
compliers.
Dept. of ECE, JIT, Davangere 28
Cost saving
• Cortex provided a greater success compared
to other vendors (Texas, ATMEL etc)
• Developers are towards decreasing overall
system cost.
• ARM cortex replaces a 4 traditional controllers
• Code re-use in applications which reduces
testing (Mi phone cost is less) and
development time.
Dept. of ECE, JIT, Davangere 29
Partners for ARM
• NXP, TEXAS, ATMEL, OKI.
• Before CORTEX, the most successful
controller from ARM was ARM7
• 1 billion microcontrollers are produced every
year
• Attractive features in CORTEX M3
– Nested interrupt up to 240.
– Memory Protection Unit
Dept. of ECE, JIT, Davangere 30
Instruction Enhancement
Dept. of ECE, JIT, Davangere 31
Thumb2 Technology
Dept. of ECE, JIT, Davangere 32
It is the super set of
previous 16bit thumb
instruction with extra
16bit instruction.
Why people gone for thumb 2 ?
Thumb 2 Technology
• Extended version of Thumb Instruction Set
Architecture (ISA)
• Benefits
– Ease to use no overhead of switching
– Code size is less
– Performance is more as it has both the instruction 16
and 32 bit.
• The efficiency is enhanced by decreasing the
number of switches between ARM and thumb
Dept. of ECE, JIT, Davangere 33
Compactable of Cortex M3
• Supports only thumb2 to reduce memory and
size of processor (core).
• All instructions are executed using Thumb2
hence it not backward compatible with older
ARM.
Dept. of ECE, JIT, Davangere 34
Example illustration
• In ARM7 or ARM9 processor if there are 16 and 32 bit
they need to have a switching and code length has also
increased.
• As cortex M3 supports both 16 and 32 bit there is no
overhead, higher efficiency and code length also
decreases.
• Feature:
– Hardware divide support
– Multiplication
– Data crunching performance – large data processing
(Hadoop)
– Unaligned data access is included which were in high end.
Dept. of ECE, JIT, Davangere 35
Application of CORTEX M3
• Low Cost microcontroller: lower power, less cost and
most important ease to use made people to choose
this.
• Automotive: has lesser interrupt latency and supports
upto 240 interrupts hence adopted in automotive
industry.
• Data Communication: bluetooth, zigbee, modem,
serial communications are supported.
• Industrial Control: fast response are needed hence it is
needed.
• Consumer Products: Memory protection unit as per
customer security.
Dept. of ECE, JIT, Davangere 36
Architecture of ARM Cortex M3
Dept. of ECE, JIT, Davangere 37
2 stairs but reaches
common terrace.
Back : Conti.
Conti.
• Fundament: 32bit Microcontroller means
32bit register, memory interface and data path
• Harvard architecture hence performance
increases.
• It has a multiple bus interface but shares a
common memory i.e. 8GB
• Complex application requests more memory
features i.e secure of data cortex provides
Memory Protection Unit (MPU).
Dept. of ECE, JIT, Davangere 38
Conti.
• External cache if required
• Supports both little and big endian memory
• Debugging support such as breakpoints and
watchdog at software and hardware ( through
debugging interface )
Dept. of ECE, JIT, Davangere 39
Components of Architecture
• Registers Register_bank_tecxtbook.JPG
• Ro- R15 registers ; R0 – R12 general purpose
• Low and high registers.
• Low Registers – R0 to R7- based on access
Dept. of ECE, JIT, Davangere 40
Stack Pointers- R3
• In cortex M3 has two stack pointer, they are
combined and one is visible at once.
– Main Stack Pointer (MSP)
– Process Stack Pointer (PSP)
• The lowest two bits are zero which says that
they are word aligned.
Dept. of ECE, JIT, Davangere 41
Main Stack Pointer
• The stack is a memory structure where your
programs can store data. The stack pointer is
the variable that "points" to the current
location of the top of the stack.
• MSP is the default stack pointer used in OS
and exception handling
Dept. of ECE, JIT, Davangere 42
Processor Stack Pointer (PSP)
• In all modes its runs on Main Stack Pointer but
during only SUPERIOR CALLS ( It is one of the
mode where OS allows to access all the
system resources)
• In User application codes the PSP are used.
Dept. of ECE, JIT, Davangere 43
Link Register- R14
• It stores the return information for
subroutines, function calls, and exceptions.
• On reset, the processor sets the LR value
to 0xFFFFFFFF.
Dept. of ECE, JIT, Davangere 44
Program Counter- R15
• The Program Counter (PC) is accessed by PC (or R15). It
is incremented by the size of the instruction executed
(which is always four bytes).
• Branch instructions load the destination address into
PC. You can also load the PC directly using data
operation instructions. For example, to branch to the
address in a general purpose register, use:
– MOV PC,R0
• During execution, PC does not contain the address of
the currently executing instruction.
Dept. of ECE, JIT, Davangere 45
Special Registers
Dept. of ECE, JIT, Davangere 46
Types of Special Registers
• There are three types of Special Registers
– Program Status Registers (PSRs)
– Interrupt Mask Registers.
– Control Register.
Dept. of ECE, JIT, Davangere 47
Types.
• PSR- Provide arithmetic and logic processing flags (zero flag and
carry flag), execution status, and current executing interrupt
number.
• N Negative
• Z Zero
• C Carry/borrow
• V Overflow
• Q Sticky saturation flag (Stack is overflow or saturation )
• ICI/IT Interrupt- Continuable Instruction (ICI) bits, IF-THEN
instruction status bit
• T Thumb state, always 1; trying to clear this bit will cause a fault
exception
• Exception number Indicates which exception the processor is
handling
Dept. of ECE, JIT, Davangere 48
Interrupt Mask & Control Registers
• Types
– PRIMASK – Disable all interrupts except the non-
maskable interrupt (NMI) and hard fault.
– NMI – example: warning of high tides.
– FAULTMASK- Disable all interrupts except the NMI
– BASEPRI- Disable all interrupts of specific priority
level or lower priority level
• Control Register - Define privileged status and
stack pointer selection.
• Interrupt Masking
Dept. of ECE, JIT, Davangere 49
Operating Mode
Dept. of ECE, JIT, Davangere 50
Operating Mode
Dept. of ECE, JIT, Davangere 51
• Two modes
– Operation mode – Thread mode and handler mode
– Privilege Level – privileged and user mode.
• Operation mode- used to determine processor is
running in normal(main program) or in exception
such as interrupt program.
• Thread mode(normal) is entered when the reset
is pressed or program return from exceptions.
Handler Mode
• Handler mode will be entered as a result of an
exception.
• During this mode core enters to privilege
mode
• During privileged mode any memory can be
accessed but except memory reserved by
MPU(Memory Protection Unit)
Dept. of ECE, JIT, Davangere 52
Privileged and User Mode
• Privileged – this is a mode where code is
provided with a full stretch access to memory
except MPU memory.
• USER mode- it has a limited access rights.
Dept. of ECE, JIT, Davangere 53
Switching of Privileged and User
Dept. of ECE, JIT, Davangere 54
•If program in privileged in can be switched to user but reverse is not possible.
• By having this unauthorized person can't alter system configuration (boot sequence,
boot services, listing I/O, OS data and programs)
•ANDORID : Applications in user mode initially once user provides access they can
use it.
•Location access by GPS to MAPS application.
•ShareIt : if hotspot access is provided it connects to other user or else no.
Nested Vectored Interrupt Controller
(NVIC)
• Features
– Nested interrupt support
– Vectored interrupt support
– Dynamic priority changes support
– Reduction of interrupt latency
– Interrupt masking
Dept. of ECE, JIT, Davangere 55
Nested Interrupt Support
• What is nested means
• NVIC supports nested interrupt support
• Programmed (S/w) priority given for all interrupts
• Working
– When interrupt occurs NVIC compares the priority of
the running with occurred interrupt.
– If the new interrupt is higher than current interrupt
then execution switches to the new interrupt request.
• This is called as nested.
Dept. of ECE, JIT, Davangere 56
Vector Interrupt Support
• Posses less time to serve interrupt request.
• Cortex M3 supports Vector Interrupt.
• The difference is when interrupt occurred
starting address of ISR is loaded from Vector
table.
• Hence software is not needed find the starting
address of ISR. Hence time required to serve is
less
Dept. of ECE, JIT, Davangere 57
Dynamic Priority Changes Support
• During the runtime the priority of the
interrupt can be varied.
• Till the updating of priority the current serving
of ISR is blocked
• Priority can be changed without any risk
during run time.
Dept. of ECE, JIT, Davangere 58
Dept. of ECE, JIT, Davangere 59
Reduction of Interrupt Latency
• Automatic saving and restoring some register
contents, reducing delay in switching from one
ISR to another.
• How
– The processor automatically stacks its state on
exception entry and un-stacks previous state on
exception exit, with no instruction overhead. This
provides low latency exception handling.
Dept. of ECE, JIT, Davangere 60
Interrupt Masking
• Based on the priority level the interrupts are masked.
Masked means
• Providing the priority level to each interrupt
• Non-Masking interrupts means
– These types of interrupts are never ignored by system.
• The masking registers takes care that time critical tasks
should finish within pre-allotted time.
• Masking registers are Interrupt Mask Registers
Dept. of ECE, JIT, Davangere 61
Memory Map
• The build-in peripherals (interrupt controller, debug)
these are accessed by simple memory access & also
have pre-defined memory map.
• By using C program which is easy to integrate on
SOC and speeder to access them.
• 4GB memory space
• Internal bus infrastructure structure are optimized.
• Data memory can also be executed into code region
– ......ClassblockTrans.s
• Program can be executed from external RAM region
as-well.
Dept. of ECE, JIT, Davangere 62
Memory space
Dept. of ECE, JIT, Davangere 63
Bus interface
• Fetching data and instruction is at a time – has
several bus interface. Mainly three
– Code memory bus
– System bus
– Private peripheral bus
Dept. of ECE, JIT, Davangere 64
Code memory buses
• Code memory region are accessed by code
memory bus
• Physically has two buses
– I-Code
– D-Code
• These are optimized for instruction fetches for
best instruction execution speed.
Dept. of ECE, JIT, Davangere 65
System bus
• Gives access to memory and peripherals.
• Access for
– SRAM
– Peripherals
– External RAM
– External devices
– Memory regions at system level.
Dept. of ECE, JIT, Davangere 66
Private Peripheral Bus
• These buses are reserved to access the private
peripherals bus such as debugging
components.
• Access to a part of system level memory.
Dept. of ECE, JIT, Davangere 67
MPU
• This unit is used to provide the security to selected
memory area based on rules.
• If rules are violated a code fault is generated if possible
MPU will correct or fault is pop to user.
• In OS, it sets the MPU to protect OS data shouldn’t be
accessed by other application.
• It makes some memory slots as READ-ONLY to prevent
erase of data.
• Memory isolation for numerous tasks in multitasking
system.
– Scenario is two nuclear plants with shared memory.
– Problem is staled information of temperature.
Dept. of ECE, JIT, Davangere 68
Instruction Set
• Cortex M3 supports Thumb 2 instruction set which
allows both 16 and 32 bit
• Previous ARM processor has two operating state 32 bit
and 16 bit
– 32 bit can execute all instruction with full power
– 16bit has higher instruction code density but doesn’t
support all the functionality of ARM.
• For some applications both 16 and 32 bit instructions
are mixed
– Overhead are
• Compilation should performed separately.
• Switching between states which increase code length as well
Dept. of ECE, JIT, Davangere 69
Switching of thumb to arm & vice
versa
Dept. of ECE, JIT, Davangere 70
Advantage of cortex M3 instruction set
• No state switching overhead, saving both execution time
and instruction space.
• No need to separate ARM code and Thumb code source
files, making software development and maintenance
easier.
• Has many interesting and powerful instruction
– UFBX, BFI, and BFC- Bit field extract, insert, and clear
instructions
– UDIV and SDIV
– WFE, WFI, and SEV: Wait-For-Event, Wait-For-Interrupts, and
Send-Event; these allow the processor to enter sleep mode and
to handle task synchronization on multiprocessor systems
– MSR and MRS – Move from general purpose to special register
and vice versa.
Dept. of ECE, JIT, Davangere 71
CORTEX M3 supporting instructions
• It supports only thumb 2 instruction- already
previous ARM program need to change for
new architecture.
• It doesn’t support SIMD and few thumb
instructions such as BLX( branch with link and
exchange) , SETEBD (SET ENDIAN) , some
change process state (CPS).
Dept. of ECE, JIT, Davangere 72
Interrupts and Exceptions
• It has a exception model, introduced in the
ARMv7-M architecture.
• System exceptions and external Interrupt
requests
• There is no fast interrupt but nester interrupt,
priority are supported
• Features
– Not only external, internal interrupts are also
supported such as system fault handling.
– Predefined exceptions.
Dept. of ECE, JIT, Davangere 73
Predefined exceptions
Dept. of ECE, JIT, Davangere 74
Low Power and High Energy Efficiency
• One important feature is low power is
performed using sleep and deep sleep mode.
• Low gate count and design techniques reduces
the circuit activity which in turn reduces
consumption of active power.
• Processing time is short and code size is less.
• Wakeup Interrupt Controller- sleep to awake
mode almost immediate. Hence for ultra low
power application these are used.
Dept. of ECE, JIT, Davangere 75
Debugging Support
• Debugging Features
– Program execution control those are
• Halting,
• Stepping,
• Breakpoints,
• Trace,
• Data watchpoints, register and memory access.
• Coresight Architecture is employed in CORTEX
M3. As previous ARM Cortex also doesn’t
JTAG(Joint Test Action Group)
Dept. of ECE, JIT, Davangere 76
Conti.
• Instead of JTAG, a bus interface called as DAP
(Debug Access Port) connected to core.
• Through this bus interface external debugger
can debug the hardware even the processor is
running.
• The control of this bus interface is carried out
by a Debug Port (DP) device.
• DPs has Serial Wire JTAG Debug Port
Dept. of ECE, JIT, Davangere 77
Conti.
• A JTAG-DP or SW-Dp manufacture can choose
one among this for debug interface.
• Other complier Embedded Trace Macrocell
allows instruction to trace through Trace Port
Interface Unit.
• The debug host (Computer) collected
executed instructions information via external
trace capturing hardware. Architecture of ARM Cortex M3
Dept. of ECE, JIT, Davangere 78
Conti.
• Inside a controller debug is supported by
various blocks such as breakpoints,
watchpoints, fault conditions or external
debug request input.
• When debug occurs the processor (Cortex M3)
goes to halt or execute debug monitor handler
Dept. of ECE, JIT, Davangere 79
Data watchpoint
• This function is provided by Data Watchpoint
and Trace unit in Cortex M3
• Used for
– To stop the processor
– To generate data trace information
• Example : register value or memory update
• When trace is used the traced data is
outputted via Trace Port Interface Unit
Dept. of ECE, JIT, Davangere 80
Conti.
• Flash Patch and Breakpoint (FPB)- provide a simple
breakpoint function or remap an instruction access
from Flash to a different location in SRAM
• Instrumentation Trace Macrocell (ITM) provides a new
way to output data to a debugger. By writing data to
register memory in the ITM, a debugger can collect the
data via a trace interface and display or process them.
• This method is easy to use and faster than JTAG output.
• All these debugging components are controlled via DAP
interface bus and trace information are fetched from
TPIU.
Dept. of ECE, JIT, Davangere 81
Features of Debug
• Supports JTAG or serial Wire debug interfaces
• Memory or processor status are accessed during
core running as well
• Built in support for six breakpoints and four
watchpoints
• Optional Embedded Trace Macrocell
• Data trace using Data Watchpoint and Trace
• Four watchpoints and six breakpoints hardware
• Fault status register, new fault exceptions and
flash patch operations.
Dept. of ECE, JIT, Davangere 82
Stack Push and POP
Dept. of ECE, JIT, Davangere 83
Special Registers with Programs
• Stack pointer (SP)(R13) decrements when new data is
stored and incremented when data is re-stored
– PUSH {R0} ; R13=R13-4, then Memory[R13] = R0
– POP {R0} ; R0 = Memory[R13], then R13 = R13 + 4
• PUSH, POP is used to save register contents to stack
memory at start of exception and restore when
exception ends.
• Can use multiple registers
– PUSH {R0-R7, R12, R14} ; Save registers
– POP {R0-R7, R12, R14} ; Restore registers
– BX R14 ; Return to calling function
Dept. of ECE, JIT, Davangere 84
Programming for link register (R14)
• main ; Main program
...
BL function1 ; Call function1 using Branch with Link
instruction. ; PC = function1 and
; LR = the next instruction in main
...
function1
... ; Program code for function 1
BX LR ; Return
Dept. of ECE, JIT, Davangere 85
Special Register
• These are accessed by MSR and MRS
• MRS <reg>,<special_reg> ; read special reg
• MSR <Special_reg>,<reg>; write to special reg
Dept. of ECE, JIT, Davangere 86
Program Status Registers
• MRS r0, APSR ; Read Flag state into R0
• MRS r0, IPSR ; Read Exception/Interrupt
• MRS r0, EPSR ; Read Execution state
• MSR APSR, r0 ; Write Flag state
• EPSR and IPSR are read only
• APSR is writable (can change)
• When all are accessed as a collective item, the
name xPSR is used.
Dept. of ECE, JIT, Davangere 87
PSR in the Cortex-M3.
Dept. of ECE, JIT, Davangere 88
Combined Program Status Registers (xPSR) in the Cortex-M3.
PSR in Older ARM
Dept. of ECE, JIT, Davangere 89
MOV R0 , PSR ; while accessing combined PSR
Uses of Interrupt Masking
• PRIMASK (1 bit) and BASEPRI (8-bit) -
temporarily disabling interrupts. Default value
is 0 ( no masking is there)
• FAULTMASK – used by OS during temporarily
disable fault handling when a task has
crashed. (1-bit)
• During a crash there will be different faults,
the OS kernel needs time to clear these and
during that no interrupts should be generated.
Dept. of ECE, JIT, Davangere 90
Functions created based on vendors
(all companies differ this structure)
• x = __get_BASEPRI(); // Read BASEPRI register
• x = __get_PRIMARK(); // Read PRIMASK register
• x = __get_FAULTMASK(); // Read FAULTMASK register
• __set_BASEPRI(x); // Set new value for BASEPRI
• __set_PRIMASK(x); // Set new value for PRIMASK
• __set_FAULTMASK(x); // Set new value for FAULTMASK
• __disable_irq(); // Clear PRIMASK, enable IRQ
• __enable_irq(); // Set PRIMASK, disable IRQ
Dept. of ECE, JIT, Davangere 91
In assembly
• MRS r0, BASEPRI ; Read BASEPRI register into R0
• MRS r0, PRIMASK ; Read PRIMASK register into R0
• MRS r0, FAULTMASK ; Read FAULTMASK register into R0
• MSR BASEPRI, r0 ; Write R0 into BASEPRI register
• MSR PRIMASK, r0 ; Write R0 into PRIMASK register
• MSR FAULTMASK, r0 ; Write R0 into FAULTMASK register
The PRIMASK, FAULTMASK, and BASEPRI registers cannot be set in the
user access level.
Dept. of ECE, JIT, Davangere 92
Control Register
• Used to define privilege level and the SP selection and
has two bits
• CONTROL[1] – it is always 0 in handler mode 1 for
thread or base level i.e. it is writable only in thread
mode
– used for knowing stack
• 1- alternate stack
• 0 – default stack (MSP)
• No alternate stack can be used when its in handler mode
• In thread or base level the alternate stack PSP is chosen
• CONTROL[0] – writable only in privileged state, if it
enters user state a interrupt should be generated to get
back to privileged state.
Dept. of ECE, JIT, Davangere 93
Access controller register
• In C
– x = __get_CONTROL(); // Read the current value of
CONTROL
– __set_CONTROL(x); // Set the CONTROL value to x
• In assembly
– MRS r0, CONTROL ; Read CONTROL register into R0
– MSR CONTROL, r0 ; Write R0 into CONTROL register
Dept. of ECE, JIT, Davangere 94
EXCEPTION & INTERRUPTS
• Cortex M3 supports a fixed number of
exceptions and interrupts (IRQ)
• Interrupts number are decided by
manufacturer
• Interrupts are generated by peripherals.
• Typical number of interrupts are 16 or 32
many Micro-controller are lesser or greater.
Dept. of ECE, JIT, Davangere 95
Non-Maskable Interrupt
• Use of NMI are different in different vendors
• Most of the applications NMI is connected to
watchdog timer or voltage monitoring blocks
– voltage-monitoring block that warns the processor
when the voltage drops below a certain level.
– NMI are activated at any time as they are next to
reset.
Dept. of ECE, JIT, Davangere 96
Exceptions Types
Dept. of ECE, JIT, Davangere 97
Vector Table
• Whenever the exceptions occurs, corresponding
handler is executed by using starting address of it
stored in vector table.
• The vector table is an array of word data inside
the system memory, each representing the
starting address of one exception type.
• Vector table are re-locatable and it is performed
by NVIC
• After reset, this relocation control register is
reset to 0; therefore, the vector table is located in
address 0x0 after reset.
Dept. of ECE, JIT, Davangere 98
Example
Dept. of ECE, JIT, Davangere 99
• How the addressing is made
– Exceptions starts after reset
– In reset the vector table value is 0
– Exception 1 = 4 times the address of reset vector
– Exception 2 = 4 times the address of exception 1
– Here 4 is each word has 4 bytes.
Vector Table
Dept. of ECE, JIT, Davangere 100
Stack Operation
• Have two types one is ascending stack and
another one is descending stack
– We use descending one SP decrements before store
• Push of single register and corresponding pop
• Pushing multiple registers and pop.
• Pushing and pop without return
– Push the contents of registers and link register
– Pop the same and feed the address of link register to
PC
Dept. of ECE, JIT, Davangere 101
Single register in PUSH/POP
Dept. of ECE, JIT, Davangere 102
Multiple Register PUSH/POP
Dept. of ECE, JIT, Davangere 103
Without Return (Branch)
Dept. of ECE, JIT, Davangere 104
Two stack Model
• We know that stack has two models one is
– MSP ( Main Stack Pointer)
– PSP (Processor Stack Pointer)
• Control register are used to switch between
them Control [1] – 0 MSP
Dept. of ECE, JIT, Davangere 105
Thread and Handler use Main Stack
Dept. of ECE, JIT, Davangere 106
Thread mode used PSP and Handler
MSP
Dept. of ECE, JIT, Davangere 107
Reset Sequence
• When resets, core reads as follows
– Starting address of R13 ( SP)
– Reset vector (starting address of program
execution)
Dept. of ECE, JIT, Davangere 108
Initial Stack Pointer Value and Initial PC
as Example
Dept. of ECE, JIT, Davangere 109
THANK YOU
Dept. of ECE, JIT, Davangere 110

More Related Content

What's hot

Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051Muthu Manickam
 
Introduction to microprocessor
Introduction to microprocessorIntroduction to microprocessor
Introduction to microprocessorRamaPrabha24
 
Introduction to Embedded Systems I : Chapter 1
Introduction to Embedded Systems I : Chapter 1Introduction to Embedded Systems I : Chapter 1
Introduction to Embedded Systems I : Chapter 1Moe Moe Myint
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051hello_priti
 
Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems VijayKumar5738
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontrollerAshish Ranjan
 
Applications of microprocessor
Applications of microprocessorApplications of microprocessor
Applications of microprocessorAnjali Agrawal
 
Introduction to embedded systems
Introduction  to embedded systemsIntroduction  to embedded systems
Introduction to embedded systemsRAMPRAKASHT1
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERsravannunna24
 
Chapter 4 Embedded System: Application and Domain Specific
Chapter 4 Embedded System: Application and Domain SpecificChapter 4 Embedded System: Application and Domain Specific
Chapter 4 Embedded System: Application and Domain SpecificMoe Moe Myint
 
Memory & I/O interfacing
Memory & I/O  interfacingMemory & I/O  interfacing
Memory & I/O interfacingdeval patel
 
Pipelining approach
Pipelining approachPipelining approach
Pipelining approachGopinathD17
 
Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 IntroductionDr. Pankaj Zope
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESDr.YNM
 

What's hot (20)

Programming with 8085
Programming with 8085Programming with 8085
Programming with 8085
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051
 
Introduction to microprocessor
Introduction to microprocessorIntroduction to microprocessor
Introduction to microprocessor
 
Introduction to Embedded Systems I : Chapter 1
Introduction to Embedded Systems I : Chapter 1Introduction to Embedded Systems I : Chapter 1
Introduction to Embedded Systems I : Chapter 1
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
TMS320C5x
TMS320C5xTMS320C5x
TMS320C5x
 
Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems Communication Interface of The Embedded Systems
Communication Interface of The Embedded Systems
 
Pentium processor
Pentium processorPentium processor
Pentium processor
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontroller
 
ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
 
Applications of microprocessor
Applications of microprocessorApplications of microprocessor
Applications of microprocessor
 
Introduction to embedded systems
Introduction  to embedded systemsIntroduction  to embedded systems
Introduction to embedded systems
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
 
Chapter 4 Embedded System: Application and Domain Specific
Chapter 4 Embedded System: Application and Domain SpecificChapter 4 Embedded System: Application and Domain Specific
Chapter 4 Embedded System: Application and Domain Specific
 
Memory & I/O interfacing
Memory & I/O  interfacingMemory & I/O  interfacing
Memory & I/O interfacing
 
Pipelining approach
Pipelining approachPipelining approach
Pipelining approach
 
Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 Introduction
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 
Ec8791 lpc2148
Ec8791 lpc2148Ec8791 lpc2148
Ec8791 lpc2148
 

Similar to Module 1 - ARM 32 Bit Microcontroller

ES Module_1.pptx
ES Module_1.pptxES Module_1.pptx
ES Module_1.pptxsarala9
 
LECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSLECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSDr.YNM
 
18CS44-MODULE1-PPT.pptx
18CS44-MODULE1-PPT.pptx18CS44-MODULE1-PPT.pptx
18CS44-MODULE1-PPT.pptxKokilaK25
 
ARM Microcontroller and Embedded Systems (17EC62) – ARM – 32 bit Microcontrol...
ARM Microcontroller and Embedded Systems (17EC62) – ARM – 32 bit Microcontrol...ARM Microcontroller and Embedded Systems (17EC62) – ARM – 32 bit Microcontrol...
ARM Microcontroller and Embedded Systems (17EC62) – ARM – 32 bit Microcontrol...Shrishail Bhat
 
18CS44-MES-Module-1.pptx
18CS44-MES-Module-1.pptx18CS44-MES-Module-1.pptx
18CS44-MES-Module-1.pptxrakshitha481121
 
ARM Microcontrollers and Embedded Systems-Module 1_VTU
ARM Microcontrollers and Embedded Systems-Module 1_VTUARM Microcontrollers and Embedded Systems-Module 1_VTU
ARM Microcontrollers and Embedded Systems-Module 1_VTUGirish M
 
Arm Processors Architectures
Arm Processors ArchitecturesArm Processors Architectures
Arm Processors ArchitecturesMohammed Hilal
 
MODULE 1 MES.pptx
MODULE 1 MES.pptxMODULE 1 MES.pptx
MODULE 1 MES.pptxManvanthBC
 
How to Select Hardware for Internet of Things Systems?
How to Select Hardware for Internet of Things Systems?How to Select Hardware for Internet of Things Systems?
How to Select Hardware for Internet of Things Systems?Hannes Tschofenig
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded Systems
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I   Core of Embedded SystemsSYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I   Core of Embedded Systems
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded SystemsArti Parab Academics
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scopeArshit Rai
 
Brochure (2016-01-30)
Brochure (2016-01-30)Brochure (2016-01-30)
Brochure (2016-01-30)Jonah McLeod
 
Performance of State-of-the-Art Cryptography on ARM-based Microprocessors
Performance of State-of-the-Art Cryptography on ARM-based MicroprocessorsPerformance of State-of-the-Art Cryptography on ARM-based Microprocessors
Performance of State-of-the-Art Cryptography on ARM-based MicroprocessorsHannes Tschofenig
 

Similar to Module 1 - ARM 32 Bit Microcontroller (20)

ES Module_1.pptx
ES Module_1.pptxES Module_1.pptx
ES Module_1.pptx
 
ankit
ankitankit
ankit
 
LECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSLECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORS
 
18CS44-MODULE1-PPT.pptx
18CS44-MODULE1-PPT.pptx18CS44-MODULE1-PPT.pptx
18CS44-MODULE1-PPT.pptx
 
ARM UNIT4 PPTold.pptx
ARM UNIT4 PPTold.pptxARM UNIT4 PPTold.pptx
ARM UNIT4 PPTold.pptx
 
ARM Microcontroller and Embedded Systems (17EC62) – ARM – 32 bit Microcontrol...
ARM Microcontroller and Embedded Systems (17EC62) – ARM – 32 bit Microcontrol...ARM Microcontroller and Embedded Systems (17EC62) – ARM – 32 bit Microcontrol...
ARM Microcontroller and Embedded Systems (17EC62) – ARM – 32 bit Microcontrol...
 
18CS44-MES-Module-1.pptx
18CS44-MES-Module-1.pptx18CS44-MES-Module-1.pptx
18CS44-MES-Module-1.pptx
 
ARM cortex A15
ARM cortex A15ARM cortex A15
ARM cortex A15
 
ARM Microcontrollers and Embedded Systems-Module 1_VTU
ARM Microcontrollers and Embedded Systems-Module 1_VTUARM Microcontrollers and Embedded Systems-Module 1_VTU
ARM Microcontrollers and Embedded Systems-Module 1_VTU
 
Arm Processors Architectures
Arm Processors ArchitecturesArm Processors Architectures
Arm Processors Architectures
 
ARM.pdf
ARM.pdfARM.pdf
ARM.pdf
 
Ijetr042175
Ijetr042175Ijetr042175
Ijetr042175
 
MODULE 1 MES.pptx
MODULE 1 MES.pptxMODULE 1 MES.pptx
MODULE 1 MES.pptx
 
How to Select Hardware for Internet of Things Systems?
How to Select Hardware for Internet of Things Systems?How to Select Hardware for Internet of Things Systems?
How to Select Hardware for Internet of Things Systems?
 
Phytec_Intro_092018
Phytec_Intro_092018Phytec_Intro_092018
Phytec_Intro_092018
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded Systems
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I   Core of Embedded SystemsSYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I   Core of Embedded Systems
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded Systems
 
Summer training embedded system and its scope
Summer training  embedded system and its scopeSummer training  embedded system and its scope
Summer training embedded system and its scope
 
Brochure (2016-01-30)
Brochure (2016-01-30)Brochure (2016-01-30)
Brochure (2016-01-30)
 
Training report on embedded sys_AVR
Training report on embedded sys_AVRTraining report on embedded sys_AVR
Training report on embedded sys_AVR
 
Performance of State-of-the-Art Cryptography on ARM-based Microprocessors
Performance of State-of-the-Art Cryptography on ARM-based MicroprocessorsPerformance of State-of-the-Art Cryptography on ARM-based Microprocessors
Performance of State-of-the-Art Cryptography on ARM-based Microprocessors
 

Recently uploaded

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 

Module 1 - ARM 32 Bit Microcontroller

  • 1. ARM Microcontroller and Embedded Systems Prof. Amogha B Asst Prof. Dept. of ECE Visvesvaraya Technological University, Belagavi. Jain Institute of Technology, Davangere. (A Unit of Jain Group of Institutions, Bangalore)
  • 2. Brief about subject • Module 1- • Module 2- • Module 3- • Module 4- • Module 5- C:UsersAmoghaDesktop15EC62.pdf 2Dept. of ECE, JIT, Davangere
  • 3. Before entering the syllabus • Shall see about the some of the basics • A general Discussion • IF X bits controller means what – Microprocessor 64 bit – Microcontroller 8 , 16, 32 bits • Think 3Dept. of ECE, JIT, Davangere
  • 4. ARM Microcontroller • ARM founded in November 1990 – Advanced RISC Machines – 32 bit Microcontroller • Company headquarters in Cambridge, UK – Processor design centers in Cambridge, Austin, and Sophia Antipolis. (They won’t manufacture Micro-controllers) – Sales, support, and engineering offices all over the world • What RISC means- Reduced Instruction Set Computer • What CISK means- 4Dept. of ECE, JIT, Davangere
  • 5. RISK and CISC CISC RISC Full form Full form Includes multi clock for complex instr. Single clock Load and store is used for memory to memory Register to register Small code size Large code size but time for execution remains same 5Dept. of ECE, JIT, Davangere
  • 6. ARM • Assembly for arm we write only for understanding the architecture. – Beyond add/sub everything becomes complex and its lost. • ARM cortex are not mean for writing assembly they actually not designed for it. Critically mean for C • With C coding it becomes more Powerful. 6Dept. of ECE, JIT, Davangere
  • 7. 1st Critical thinking of ARM developers • They made 32 bit memory access • During the launch of ARM all other companies were on 16bit and almost all the instructions are 16bit. • Memory under utilization 60-70% hence Thumb mode. • ARM with pipelined makes 2 instructions to run as 32bit which makes it faster. 7Dept. of ECE, JIT, Davangere
  • 8. Thumb mode • It became too much famous almost famous as cortex all instructions executes at faster rate. Problem of THUMB • It doesn’t support all the instructions of ARM • When thumb doesn’t supports it should switch to ARM mode hence for switching it became overhead. 8Dept. of ECE, JIT, Davangere
  • 9. THUMB2 • To address this they have came up with hybrid architecture it is called as thumb 2 • This architecture is not having switching issue and it is in ARM-CORTEX series. • Important for working it access 16 bit memory and carries work or process in ARM architecture. 9Dept. of ECE, JIT, Davangere
  • 10. Graph 10Dept. of ECE, JIT, Davangere
  • 11. Cortex has three division • CORTEX A – application specific such as OS(IOS, android or windows) mobile phones applications. • CORTEX M- Microcontroller a general purpose widely used. • CORTEX R- Real time applications in medical and defense sectors. – Hardware support ex: Controller supports adder means ????? 11Dept. of ECE, JIT, Davangere
  • 12. What ARM supplies and what partners of ARM performs 12Dept. of ECE, JIT, Davangere
  • 13. Architecture In detail (SEE IN NEXT SLIDES) AMBA – 1996 Advanced Microcontroller Bus Architecture 13Dept. of ECE, JIT, Davangere
  • 14. Halfword and signed halfword / byte support System mode Thumb instruction set (v4T) Improved interworking Saturated arithmetic DSP MAC instructions Extensions: Jazelle (5TEJ) SIMD Instructions Multi-processing v6 Memory architecture Unaligned data support Extensions: Thumb-2 (6T2) TrustZone® (6Z) Multicore (6K) Thumb only (6-M)  Note that implementations of the same architecture can be different  Cortex-A8 - architecture v7-A, with a 13-stage pipeline  Cortex-A9 - architecture v7-A, with an 8-stage pipeline Thumb-2 Architecture Profiles 7-A - Applications 7-R - Real-time 7-M - Microcontroller v4 v5 v6 v7 Development of the ARM Architecture 14Dept. of ECE, JIT, Davangere
  • 15. Nomenclature of ARM (Naming) CRITICALLY Imp. 15Dept. of ECE, JIT, Davangere
  • 16. Difference • Simulation – Ex: Dr driving game is a excellent example • Emulation – Games played at M2 • Some works in simulation but fails in real world • Which works in Emulation works everywhere. • 8051 was not having EMULATOR/ ICE on board. 16Dept. of ECE, JIT, Davangere
  • 17. 4 Critical Thinking made ARM to stand 1st Why its called a wonderful architecture and it proved to be same. 4. Interrupts nested ( upto 240). 17Dept. of ECE, JIT, Davangere
  • 18. Oscillators • Three oscillators • External • Internal • RTC- Real Time Clock 18Dept. of ECE, JIT, Davangere
  • 19. Interrupts • What is interrupts? • Ex: 19Dept. of ECE, JIT, Davangere
  • 20. What is blue screen • Hint : fatal error 20Dept. of ECE, JIT, Davangere
  • 21. Exception • Invalid behavior are identified by ARM and provided to user. 21Dept. of ECE, JIT, Davangere
  • 22. Which company focus on CISK architecture download.png 22Dept. of ECE, JIT, Davangere
  • 23. Assembly program structure • Area – directive which allocates the memory for code and data • Program name- it should be different for code and data • Entry – start of program • Export label_name (practical) • End- of program • Important thing is have one endless loop in embedded systems. 23Dept. of ECE, JIT, Davangere
  • 24. Lets write some simple code • For instance adding two number and store in another register • Mov r0, #5 ; it can access only registers not memory • ADD r0, r1, r2 ; r0 = r1 + r2 • Load instruction LDR – Load to memory – Pseudo information • Store instruction STR – Store from memory to register. 24Dept. of ECE, JIT, Davangere
  • 25. Structure of C with ARM • Include lpc17xx.h • Global variables or define • Int main() • Main program • To write code in any language we need to know – Keyword – Looping or syntax – Logic ( Most Important) 25Dept. of ECE, JIT, Davangere
  • 26. OUTLINE • Thumb-2 technology and applications of ARM, • Architecture of ARM Cortex M3, • Various Units in the architecture, Debugging support, • General Purpose Registers, Special Registers, exceptions, interrupts, stack operation, reset sequence 26Dept. of ECE, JIT, Davangere
  • 27. Introduction 27Dept. of ECE, JIT, Davangere • The market of the microcontroller is vast every year 20 billions are manufactured and they are released for sale. • In the competitive world to meet the industrial demands the microcontrollers should posses higher performance. •Ex: Performing more work without increase in the clock frequency •It should support communication peripherals such as USB, UART, Ethernet etc. •Enhance the user interface, multimedia requirements, system speed etc. •In 2006 the ARM CORTEX family have entered into market •Cortex M3 made a excellent performance with less gates (12,000) which covers features of the previously launched high-end controllers.
  • 28. Market demands for 32bit Microcontroller • Greater Performance Efficiency : with less power and frequency should need more work • Interrupt latency • Improved code density • Easy to use : migrating of programs from 8 to 32 bit • Lower cost : less than a dollar • Wide choice of development tools : companies must posses evaluation and full version of compliers. Dept. of ECE, JIT, Davangere 28
  • 29. Cost saving • Cortex provided a greater success compared to other vendors (Texas, ATMEL etc) • Developers are towards decreasing overall system cost. • ARM cortex replaces a 4 traditional controllers • Code re-use in applications which reduces testing (Mi phone cost is less) and development time. Dept. of ECE, JIT, Davangere 29
  • 30. Partners for ARM • NXP, TEXAS, ATMEL, OKI. • Before CORTEX, the most successful controller from ARM was ARM7 • 1 billion microcontrollers are produced every year • Attractive features in CORTEX M3 – Nested interrupt up to 240. – Memory Protection Unit Dept. of ECE, JIT, Davangere 30
  • 31. Instruction Enhancement Dept. of ECE, JIT, Davangere 31
  • 32. Thumb2 Technology Dept. of ECE, JIT, Davangere 32 It is the super set of previous 16bit thumb instruction with extra 16bit instruction. Why people gone for thumb 2 ?
  • 33. Thumb 2 Technology • Extended version of Thumb Instruction Set Architecture (ISA) • Benefits – Ease to use no overhead of switching – Code size is less – Performance is more as it has both the instruction 16 and 32 bit. • The efficiency is enhanced by decreasing the number of switches between ARM and thumb Dept. of ECE, JIT, Davangere 33
  • 34. Compactable of Cortex M3 • Supports only thumb2 to reduce memory and size of processor (core). • All instructions are executed using Thumb2 hence it not backward compatible with older ARM. Dept. of ECE, JIT, Davangere 34
  • 35. Example illustration • In ARM7 or ARM9 processor if there are 16 and 32 bit they need to have a switching and code length has also increased. • As cortex M3 supports both 16 and 32 bit there is no overhead, higher efficiency and code length also decreases. • Feature: – Hardware divide support – Multiplication – Data crunching performance – large data processing (Hadoop) – Unaligned data access is included which were in high end. Dept. of ECE, JIT, Davangere 35
  • 36. Application of CORTEX M3 • Low Cost microcontroller: lower power, less cost and most important ease to use made people to choose this. • Automotive: has lesser interrupt latency and supports upto 240 interrupts hence adopted in automotive industry. • Data Communication: bluetooth, zigbee, modem, serial communications are supported. • Industrial Control: fast response are needed hence it is needed. • Consumer Products: Memory protection unit as per customer security. Dept. of ECE, JIT, Davangere 36
  • 37. Architecture of ARM Cortex M3 Dept. of ECE, JIT, Davangere 37 2 stairs but reaches common terrace. Back : Conti.
  • 38. Conti. • Fundament: 32bit Microcontroller means 32bit register, memory interface and data path • Harvard architecture hence performance increases. • It has a multiple bus interface but shares a common memory i.e. 8GB • Complex application requests more memory features i.e secure of data cortex provides Memory Protection Unit (MPU). Dept. of ECE, JIT, Davangere 38
  • 39. Conti. • External cache if required • Supports both little and big endian memory • Debugging support such as breakpoints and watchdog at software and hardware ( through debugging interface ) Dept. of ECE, JIT, Davangere 39
  • 40. Components of Architecture • Registers Register_bank_tecxtbook.JPG • Ro- R15 registers ; R0 – R12 general purpose • Low and high registers. • Low Registers – R0 to R7- based on access Dept. of ECE, JIT, Davangere 40
  • 41. Stack Pointers- R3 • In cortex M3 has two stack pointer, they are combined and one is visible at once. – Main Stack Pointer (MSP) – Process Stack Pointer (PSP) • The lowest two bits are zero which says that they are word aligned. Dept. of ECE, JIT, Davangere 41
  • 42. Main Stack Pointer • The stack is a memory structure where your programs can store data. The stack pointer is the variable that "points" to the current location of the top of the stack. • MSP is the default stack pointer used in OS and exception handling Dept. of ECE, JIT, Davangere 42
  • 43. Processor Stack Pointer (PSP) • In all modes its runs on Main Stack Pointer but during only SUPERIOR CALLS ( It is one of the mode where OS allows to access all the system resources) • In User application codes the PSP are used. Dept. of ECE, JIT, Davangere 43
  • 44. Link Register- R14 • It stores the return information for subroutines, function calls, and exceptions. • On reset, the processor sets the LR value to 0xFFFFFFFF. Dept. of ECE, JIT, Davangere 44
  • 45. Program Counter- R15 • The Program Counter (PC) is accessed by PC (or R15). It is incremented by the size of the instruction executed (which is always four bytes). • Branch instructions load the destination address into PC. You can also load the PC directly using data operation instructions. For example, to branch to the address in a general purpose register, use: – MOV PC,R0 • During execution, PC does not contain the address of the currently executing instruction. Dept. of ECE, JIT, Davangere 45
  • 46. Special Registers Dept. of ECE, JIT, Davangere 46
  • 47. Types of Special Registers • There are three types of Special Registers – Program Status Registers (PSRs) – Interrupt Mask Registers. – Control Register. Dept. of ECE, JIT, Davangere 47
  • 48. Types. • PSR- Provide arithmetic and logic processing flags (zero flag and carry flag), execution status, and current executing interrupt number. • N Negative • Z Zero • C Carry/borrow • V Overflow • Q Sticky saturation flag (Stack is overflow or saturation ) • ICI/IT Interrupt- Continuable Instruction (ICI) bits, IF-THEN instruction status bit • T Thumb state, always 1; trying to clear this bit will cause a fault exception • Exception number Indicates which exception the processor is handling Dept. of ECE, JIT, Davangere 48
  • 49. Interrupt Mask & Control Registers • Types – PRIMASK – Disable all interrupts except the non- maskable interrupt (NMI) and hard fault. – NMI – example: warning of high tides. – FAULTMASK- Disable all interrupts except the NMI – BASEPRI- Disable all interrupts of specific priority level or lower priority level • Control Register - Define privileged status and stack pointer selection. • Interrupt Masking Dept. of ECE, JIT, Davangere 49
  • 50. Operating Mode Dept. of ECE, JIT, Davangere 50
  • 51. Operating Mode Dept. of ECE, JIT, Davangere 51 • Two modes – Operation mode – Thread mode and handler mode – Privilege Level – privileged and user mode. • Operation mode- used to determine processor is running in normal(main program) or in exception such as interrupt program. • Thread mode(normal) is entered when the reset is pressed or program return from exceptions.
  • 52. Handler Mode • Handler mode will be entered as a result of an exception. • During this mode core enters to privilege mode • During privileged mode any memory can be accessed but except memory reserved by MPU(Memory Protection Unit) Dept. of ECE, JIT, Davangere 52
  • 53. Privileged and User Mode • Privileged – this is a mode where code is provided with a full stretch access to memory except MPU memory. • USER mode- it has a limited access rights. Dept. of ECE, JIT, Davangere 53
  • 54. Switching of Privileged and User Dept. of ECE, JIT, Davangere 54 •If program in privileged in can be switched to user but reverse is not possible. • By having this unauthorized person can't alter system configuration (boot sequence, boot services, listing I/O, OS data and programs) •ANDORID : Applications in user mode initially once user provides access they can use it. •Location access by GPS to MAPS application. •ShareIt : if hotspot access is provided it connects to other user or else no.
  • 55. Nested Vectored Interrupt Controller (NVIC) • Features – Nested interrupt support – Vectored interrupt support – Dynamic priority changes support – Reduction of interrupt latency – Interrupt masking Dept. of ECE, JIT, Davangere 55
  • 56. Nested Interrupt Support • What is nested means • NVIC supports nested interrupt support • Programmed (S/w) priority given for all interrupts • Working – When interrupt occurs NVIC compares the priority of the running with occurred interrupt. – If the new interrupt is higher than current interrupt then execution switches to the new interrupt request. • This is called as nested. Dept. of ECE, JIT, Davangere 56
  • 57. Vector Interrupt Support • Posses less time to serve interrupt request. • Cortex M3 supports Vector Interrupt. • The difference is when interrupt occurred starting address of ISR is loaded from Vector table. • Hence software is not needed find the starting address of ISR. Hence time required to serve is less Dept. of ECE, JIT, Davangere 57
  • 58. Dynamic Priority Changes Support • During the runtime the priority of the interrupt can be varied. • Till the updating of priority the current serving of ISR is blocked • Priority can be changed without any risk during run time. Dept. of ECE, JIT, Davangere 58
  • 59. Dept. of ECE, JIT, Davangere 59
  • 60. Reduction of Interrupt Latency • Automatic saving and restoring some register contents, reducing delay in switching from one ISR to another. • How – The processor automatically stacks its state on exception entry and un-stacks previous state on exception exit, with no instruction overhead. This provides low latency exception handling. Dept. of ECE, JIT, Davangere 60
  • 61. Interrupt Masking • Based on the priority level the interrupts are masked. Masked means • Providing the priority level to each interrupt • Non-Masking interrupts means – These types of interrupts are never ignored by system. • The masking registers takes care that time critical tasks should finish within pre-allotted time. • Masking registers are Interrupt Mask Registers Dept. of ECE, JIT, Davangere 61
  • 62. Memory Map • The build-in peripherals (interrupt controller, debug) these are accessed by simple memory access & also have pre-defined memory map. • By using C program which is easy to integrate on SOC and speeder to access them. • 4GB memory space • Internal bus infrastructure structure are optimized. • Data memory can also be executed into code region – ......ClassblockTrans.s • Program can be executed from external RAM region as-well. Dept. of ECE, JIT, Davangere 62
  • 63. Memory space Dept. of ECE, JIT, Davangere 63
  • 64. Bus interface • Fetching data and instruction is at a time – has several bus interface. Mainly three – Code memory bus – System bus – Private peripheral bus Dept. of ECE, JIT, Davangere 64
  • 65. Code memory buses • Code memory region are accessed by code memory bus • Physically has two buses – I-Code – D-Code • These are optimized for instruction fetches for best instruction execution speed. Dept. of ECE, JIT, Davangere 65
  • 66. System bus • Gives access to memory and peripherals. • Access for – SRAM – Peripherals – External RAM – External devices – Memory regions at system level. Dept. of ECE, JIT, Davangere 66
  • 67. Private Peripheral Bus • These buses are reserved to access the private peripherals bus such as debugging components. • Access to a part of system level memory. Dept. of ECE, JIT, Davangere 67
  • 68. MPU • This unit is used to provide the security to selected memory area based on rules. • If rules are violated a code fault is generated if possible MPU will correct or fault is pop to user. • In OS, it sets the MPU to protect OS data shouldn’t be accessed by other application. • It makes some memory slots as READ-ONLY to prevent erase of data. • Memory isolation for numerous tasks in multitasking system. – Scenario is two nuclear plants with shared memory. – Problem is staled information of temperature. Dept. of ECE, JIT, Davangere 68
  • 69. Instruction Set • Cortex M3 supports Thumb 2 instruction set which allows both 16 and 32 bit • Previous ARM processor has two operating state 32 bit and 16 bit – 32 bit can execute all instruction with full power – 16bit has higher instruction code density but doesn’t support all the functionality of ARM. • For some applications both 16 and 32 bit instructions are mixed – Overhead are • Compilation should performed separately. • Switching between states which increase code length as well Dept. of ECE, JIT, Davangere 69
  • 70. Switching of thumb to arm & vice versa Dept. of ECE, JIT, Davangere 70
  • 71. Advantage of cortex M3 instruction set • No state switching overhead, saving both execution time and instruction space. • No need to separate ARM code and Thumb code source files, making software development and maintenance easier. • Has many interesting and powerful instruction – UFBX, BFI, and BFC- Bit field extract, insert, and clear instructions – UDIV and SDIV – WFE, WFI, and SEV: Wait-For-Event, Wait-For-Interrupts, and Send-Event; these allow the processor to enter sleep mode and to handle task synchronization on multiprocessor systems – MSR and MRS – Move from general purpose to special register and vice versa. Dept. of ECE, JIT, Davangere 71
  • 72. CORTEX M3 supporting instructions • It supports only thumb 2 instruction- already previous ARM program need to change for new architecture. • It doesn’t support SIMD and few thumb instructions such as BLX( branch with link and exchange) , SETEBD (SET ENDIAN) , some change process state (CPS). Dept. of ECE, JIT, Davangere 72
  • 73. Interrupts and Exceptions • It has a exception model, introduced in the ARMv7-M architecture. • System exceptions and external Interrupt requests • There is no fast interrupt but nester interrupt, priority are supported • Features – Not only external, internal interrupts are also supported such as system fault handling. – Predefined exceptions. Dept. of ECE, JIT, Davangere 73
  • 74. Predefined exceptions Dept. of ECE, JIT, Davangere 74
  • 75. Low Power and High Energy Efficiency • One important feature is low power is performed using sleep and deep sleep mode. • Low gate count and design techniques reduces the circuit activity which in turn reduces consumption of active power. • Processing time is short and code size is less. • Wakeup Interrupt Controller- sleep to awake mode almost immediate. Hence for ultra low power application these are used. Dept. of ECE, JIT, Davangere 75
  • 76. Debugging Support • Debugging Features – Program execution control those are • Halting, • Stepping, • Breakpoints, • Trace, • Data watchpoints, register and memory access. • Coresight Architecture is employed in CORTEX M3. As previous ARM Cortex also doesn’t JTAG(Joint Test Action Group) Dept. of ECE, JIT, Davangere 76
  • 77. Conti. • Instead of JTAG, a bus interface called as DAP (Debug Access Port) connected to core. • Through this bus interface external debugger can debug the hardware even the processor is running. • The control of this bus interface is carried out by a Debug Port (DP) device. • DPs has Serial Wire JTAG Debug Port Dept. of ECE, JIT, Davangere 77
  • 78. Conti. • A JTAG-DP or SW-Dp manufacture can choose one among this for debug interface. • Other complier Embedded Trace Macrocell allows instruction to trace through Trace Port Interface Unit. • The debug host (Computer) collected executed instructions information via external trace capturing hardware. Architecture of ARM Cortex M3 Dept. of ECE, JIT, Davangere 78
  • 79. Conti. • Inside a controller debug is supported by various blocks such as breakpoints, watchpoints, fault conditions or external debug request input. • When debug occurs the processor (Cortex M3) goes to halt or execute debug monitor handler Dept. of ECE, JIT, Davangere 79
  • 80. Data watchpoint • This function is provided by Data Watchpoint and Trace unit in Cortex M3 • Used for – To stop the processor – To generate data trace information • Example : register value or memory update • When trace is used the traced data is outputted via Trace Port Interface Unit Dept. of ECE, JIT, Davangere 80
  • 81. Conti. • Flash Patch and Breakpoint (FPB)- provide a simple breakpoint function or remap an instruction access from Flash to a different location in SRAM • Instrumentation Trace Macrocell (ITM) provides a new way to output data to a debugger. By writing data to register memory in the ITM, a debugger can collect the data via a trace interface and display or process them. • This method is easy to use and faster than JTAG output. • All these debugging components are controlled via DAP interface bus and trace information are fetched from TPIU. Dept. of ECE, JIT, Davangere 81
  • 82. Features of Debug • Supports JTAG or serial Wire debug interfaces • Memory or processor status are accessed during core running as well • Built in support for six breakpoints and four watchpoints • Optional Embedded Trace Macrocell • Data trace using Data Watchpoint and Trace • Four watchpoints and six breakpoints hardware • Fault status register, new fault exceptions and flash patch operations. Dept. of ECE, JIT, Davangere 82
  • 83. Stack Push and POP Dept. of ECE, JIT, Davangere 83
  • 84. Special Registers with Programs • Stack pointer (SP)(R13) decrements when new data is stored and incremented when data is re-stored – PUSH {R0} ; R13=R13-4, then Memory[R13] = R0 – POP {R0} ; R0 = Memory[R13], then R13 = R13 + 4 • PUSH, POP is used to save register contents to stack memory at start of exception and restore when exception ends. • Can use multiple registers – PUSH {R0-R7, R12, R14} ; Save registers – POP {R0-R7, R12, R14} ; Restore registers – BX R14 ; Return to calling function Dept. of ECE, JIT, Davangere 84
  • 85. Programming for link register (R14) • main ; Main program ... BL function1 ; Call function1 using Branch with Link instruction. ; PC = function1 and ; LR = the next instruction in main ... function1 ... ; Program code for function 1 BX LR ; Return Dept. of ECE, JIT, Davangere 85
  • 86. Special Register • These are accessed by MSR and MRS • MRS <reg>,<special_reg> ; read special reg • MSR <Special_reg>,<reg>; write to special reg Dept. of ECE, JIT, Davangere 86
  • 87. Program Status Registers • MRS r0, APSR ; Read Flag state into R0 • MRS r0, IPSR ; Read Exception/Interrupt • MRS r0, EPSR ; Read Execution state • MSR APSR, r0 ; Write Flag state • EPSR and IPSR are read only • APSR is writable (can change) • When all are accessed as a collective item, the name xPSR is used. Dept. of ECE, JIT, Davangere 87
  • 88. PSR in the Cortex-M3. Dept. of ECE, JIT, Davangere 88 Combined Program Status Registers (xPSR) in the Cortex-M3.
  • 89. PSR in Older ARM Dept. of ECE, JIT, Davangere 89 MOV R0 , PSR ; while accessing combined PSR
  • 90. Uses of Interrupt Masking • PRIMASK (1 bit) and BASEPRI (8-bit) - temporarily disabling interrupts. Default value is 0 ( no masking is there) • FAULTMASK – used by OS during temporarily disable fault handling when a task has crashed. (1-bit) • During a crash there will be different faults, the OS kernel needs time to clear these and during that no interrupts should be generated. Dept. of ECE, JIT, Davangere 90
  • 91. Functions created based on vendors (all companies differ this structure) • x = __get_BASEPRI(); // Read BASEPRI register • x = __get_PRIMARK(); // Read PRIMASK register • x = __get_FAULTMASK(); // Read FAULTMASK register • __set_BASEPRI(x); // Set new value for BASEPRI • __set_PRIMASK(x); // Set new value for PRIMASK • __set_FAULTMASK(x); // Set new value for FAULTMASK • __disable_irq(); // Clear PRIMASK, enable IRQ • __enable_irq(); // Set PRIMASK, disable IRQ Dept. of ECE, JIT, Davangere 91
  • 92. In assembly • MRS r0, BASEPRI ; Read BASEPRI register into R0 • MRS r0, PRIMASK ; Read PRIMASK register into R0 • MRS r0, FAULTMASK ; Read FAULTMASK register into R0 • MSR BASEPRI, r0 ; Write R0 into BASEPRI register • MSR PRIMASK, r0 ; Write R0 into PRIMASK register • MSR FAULTMASK, r0 ; Write R0 into FAULTMASK register The PRIMASK, FAULTMASK, and BASEPRI registers cannot be set in the user access level. Dept. of ECE, JIT, Davangere 92
  • 93. Control Register • Used to define privilege level and the SP selection and has two bits • CONTROL[1] – it is always 0 in handler mode 1 for thread or base level i.e. it is writable only in thread mode – used for knowing stack • 1- alternate stack • 0 – default stack (MSP) • No alternate stack can be used when its in handler mode • In thread or base level the alternate stack PSP is chosen • CONTROL[0] – writable only in privileged state, if it enters user state a interrupt should be generated to get back to privileged state. Dept. of ECE, JIT, Davangere 93
  • 94. Access controller register • In C – x = __get_CONTROL(); // Read the current value of CONTROL – __set_CONTROL(x); // Set the CONTROL value to x • In assembly – MRS r0, CONTROL ; Read CONTROL register into R0 – MSR CONTROL, r0 ; Write R0 into CONTROL register Dept. of ECE, JIT, Davangere 94
  • 95. EXCEPTION & INTERRUPTS • Cortex M3 supports a fixed number of exceptions and interrupts (IRQ) • Interrupts number are decided by manufacturer • Interrupts are generated by peripherals. • Typical number of interrupts are 16 or 32 many Micro-controller are lesser or greater. Dept. of ECE, JIT, Davangere 95
  • 96. Non-Maskable Interrupt • Use of NMI are different in different vendors • Most of the applications NMI is connected to watchdog timer or voltage monitoring blocks – voltage-monitoring block that warns the processor when the voltage drops below a certain level. – NMI are activated at any time as they are next to reset. Dept. of ECE, JIT, Davangere 96
  • 97. Exceptions Types Dept. of ECE, JIT, Davangere 97
  • 98. Vector Table • Whenever the exceptions occurs, corresponding handler is executed by using starting address of it stored in vector table. • The vector table is an array of word data inside the system memory, each representing the starting address of one exception type. • Vector table are re-locatable and it is performed by NVIC • After reset, this relocation control register is reset to 0; therefore, the vector table is located in address 0x0 after reset. Dept. of ECE, JIT, Davangere 98
  • 99. Example Dept. of ECE, JIT, Davangere 99 • How the addressing is made – Exceptions starts after reset – In reset the vector table value is 0 – Exception 1 = 4 times the address of reset vector – Exception 2 = 4 times the address of exception 1 – Here 4 is each word has 4 bytes.
  • 100. Vector Table Dept. of ECE, JIT, Davangere 100
  • 101. Stack Operation • Have two types one is ascending stack and another one is descending stack – We use descending one SP decrements before store • Push of single register and corresponding pop • Pushing multiple registers and pop. • Pushing and pop without return – Push the contents of registers and link register – Pop the same and feed the address of link register to PC Dept. of ECE, JIT, Davangere 101
  • 102. Single register in PUSH/POP Dept. of ECE, JIT, Davangere 102
  • 103. Multiple Register PUSH/POP Dept. of ECE, JIT, Davangere 103
  • 104. Without Return (Branch) Dept. of ECE, JIT, Davangere 104
  • 105. Two stack Model • We know that stack has two models one is – MSP ( Main Stack Pointer) – PSP (Processor Stack Pointer) • Control register are used to switch between them Control [1] – 0 MSP Dept. of ECE, JIT, Davangere 105
  • 106. Thread and Handler use Main Stack Dept. of ECE, JIT, Davangere 106
  • 107. Thread mode used PSP and Handler MSP Dept. of ECE, JIT, Davangere 107
  • 108. Reset Sequence • When resets, core reads as follows – Starting address of R13 ( SP) – Reset vector (starting address of program execution) Dept. of ECE, JIT, Davangere 108
  • 109. Initial Stack Pointer Value and Initial PC as Example Dept. of ECE, JIT, Davangere 109
  • 110. THANK YOU Dept. of ECE, JIT, Davangere 110

Editor's Notes

  1. CISC- less code density
  2. or gate hardware are inside
  3. MMU- Memory management Unit
  4. Unaligned data access the memory which is not fully divisible by N bites i.e. consider 4 bytes should be access by 0x10000004 is aligned access Unalighned means 4 bytes from 0x10000005 here 0x10000005 is not fully divisible by 4 bytes
  5. If have separate lines data fetching won’t effect instruction pipeline
  6. Little – msb is first
  7. 2nd point access of register 32 bit can access all r0-r12 few thumb can access r0 – r7 hence it is called as low registers.
  8. SCS-System Control Space
  9. Pre-defined memory map i.e. addresses are fixed
  10. The system-level memory region contains the interrupt controller and the debug components. These devices have fixed address which helps in easy porting.
  11. Fast interrupts- these interrupts need to be served as they occur which receive from Network cards, keyboard, mouse etc
  12. Debug port specifies the use of a dedicated debug port implementing a serial communications interface for low-overhead access without requiring direct external access to the system address and data buses. The interface connects to an on-chip test access port (TAP) that implements a protocol to access a set of test registers that present chip logic levels and device capabilities of various parts.
  13. Changes T is moved to 24 M mode is removed I F are interrupt which are replaced by PRIMASK
  14. This bit is writable only when the core is in thread mode and privileged. In the user state or handler mode, writing to this bit is not allowed. Aside from writing to this register, another way to change this bit is to change bit 2 of the LR when in exception return.
  15. Exception 1 = 4 times the address of reset vector i.e. LSB of all exceptions are 1 as it indicates that is in thumb state
  16. Descending stack start from top of stack and proceeds downwards as data are pushed.