Arm 32
Arm 32
[2]
Architecture
The cortex-M3 ARM processor is a high performance
32-bit processor, which offers the significant benefits to
the developers. The ARM architecture is a ‘Harward
architecture’ which offers separate data and instruction
buses for communicating with the ROM and RAM
memories. It consist a 3-stage pipeline to fetch, decode
and execute the instructions sequentially. The Cortex
processor is a cost sensitive device which is used to
reduce the processor area and has extensive improving
interrupt handling and system debug capabilities.
[3]
Architecture Versions
Over the years, ARM has continued to develop
new processors and system blocks. These include
the popular ARM7TDMI processors, more
recently the ARM11 processor family and latest
being the ARM Cortex Processor family. Table 2.1
summarizes the various architecture versions and
processor families.
Architecture Processor Family
ARMv1 ARM1
ARMv2 ARM2, ARM3
ARMv3 ARM6, ARM7
ARMv4 StrongARM, ARM7TDMI,
ARM9TDMI
ARMv5 ARM7EJ, ARM9E,
ARM10E, XScale
ARMv6 ARM11, ARM Cortex –M
ARMv7 ARM Cortex-A, ARM Cortex-
R, ARM Cortex-M
[5]
USER Mode: The user mode is a normal mode, which
has the least number of registers. It doesn’t have SPSR
and has limited access to the CPSR
FIQ and IRQ: The FIQ and IRQ are the two interrupt
caused modes of the CPU. The FIQ is processing
interrupt and IRQ is standard interrupt. The FIQ mode
has additional five banked registers to provide more
flexibility and high performance when critical interrupts
are handled.
SVC Mode: The Supervisor mode is the software
interrupt mode of the processor to start up or reset.
Undefined Mode: The Undefined mode traps when
illegal instructions are executed. The ARM core
consists of 32-bit data bus and faster data flow.
THUMB Mode: In THUMB mode 32-bit data is
divided into 16-bits and increases the processing speed.
THUMB-2 Mode: In THUMB-2 mode the instructions
can be either 16-bit or 32-bit and it increases the
performance of the ARM cortex –M3 microcontroller.
The ARM cortex-m3 microcontroller uses only
THUMB-2 instructions.
[6]
Stack Pointer (SP).
Link Register (LR).
Program Counter (PC).
Current Program Status Register (CPSR).
Saved Program Status Register (SPSR).
The reserved registers are used for specific functions.
The SPSR and CPSR contain the status control bits
which are used to store the temporary data. The SPSR
and CPSR register have some properties that are
defined operating modes, Interrupt enable or disable
flags and ALU status flag. The ARM core operates in
two states 32-bit state or THUMBS state.
[8]
Register
The Cortex-M3 has registers R0 through R15. R13 (the
stack pointer) is banked, with only one copy of the R13
visible at a time.
R0 – R12: General Purpose Registers. These are
32 bit registers for data operations. Some 16-bit
Thumb instructions can only access a subset of
these registers (low registers R0-R7).
R13: Stack Pointers. Contains two stack
pointers. They are banked so that only one is
visible at a time.
Main Stack Pointer (MSP) – The main stack
pointer used by the Operating system and
exception handlers.
Process Stack Pointer (PSP) – used by the
application code.
R14: Link Register. When a subroutine is called,
the return address is stored in the link register.
R15: The Program Counter. The program
counter is the current program address.
The Cortex-M3 also has a number of special
registers. They are -
Program Status registers (PSR)
[9]
Interrupt Mask registers (PRIMASK,
FAULTMASK and BASEPRI).
Control register (CONTROL)
The Cortex-M3 has 18 registers in total
compared to 37 registers for traditional ARM
[10]
Reducing the 32-bit Footprint
The Cortex-M3 has a small footprint which reduces
system cost. High 32-bit performance reduces an
application's active periods, the periods where the CPU
is handling data. Reducing the active periods increases
the application's battery lifetime significantly, and the
EFM32 can spend most of the time in the efficient low
energy modes.
Memory Map
The Cortex-M3 has predefined memory maps,
which allows built in peripherals, such as the
interrupt controller and debug components, to be
[11]
accessed by simple memory access instructions.
The predefined memory map also allows the
Cortex-M3 processor to be highly optimized for
speed and ease of integration in system-on-a-chip
(SoC) designs.
The Cortex-M3 design has an internal bus
infrastructure optimized for this memory usage. In
addition, the design allows these regions to be used
differently. For example, data memory can still be
put into the CODE region, and program code can
be executed from an external Random Access
Memory (RAM) region. The Cortex-M3 memory
map is outlined in figure as shown.
Operation Modes
The Cortex-M3 processor has two modes of
operation and two privilege levels. The operation
modes (thread mode and handler mode) determine
whether the processor is running a normal program
or running an exception handler like an interrupt
handler or system exception handler. The privilege
levels provide a mechanism for safeguarding
memory accesses to critical regions as well as
providing a basic security model.
When the processor is running a main
program (thread mode), it can be either in a
privileged state or a user state, but exception
[12]
handlers can only be in a privileged state. When
the processor exits reset, it is in thread mode with
privileged access right. In this state, a program has
access to all memory ranges and can use all
supported instructions.
Software in the privileged access level can
switch the program into the user access level using
the control register. When an exception takes
place, the processor will always switch back to the
privileged state and return to the previous state
when exiting the exception handler. A user
program cannot change back to the privileged state
by writing to the control register. It has to go
through an exception handler that programs the
control register to switch the processor back into
the privileged access level when returning to
thread mode.
[14]
Interrupt Masking - Interrupts and system
exceptions can be masked based on their priority
level or masked completely using the interrupt
masking registers BASEPRI, PRIMASK, and
FAULTMASK.
[15]
For example the memory size is limited and
performance might not be sufficient. The ARM
microcontrollers runs at 100Mhz frequency and higher
performance, therefore it supports the higher level
languages. The ARM microcontroller is
programmed with different IDES such as keiluvision3,
keiluvision4, coocox and so on. A 8-bit microcontroller
use 8-bit instructions and the ARM cortex-M uses a 32-
instructions.
[16]
which is executed in a single cycle. It consists of an
instruction set to perform the arithmetic, logical
and boolean operations. The ARM is a load-store
architecture, then instructions are executed
conditionally.
Syntax: Load a // a obtained the value from the place
called a //
ADD12 // 12 is added to the load value a //
Store a // final value is stored in the variable a//
The assembly language programming is developed by
the mnemonics such as ADD, SUB, MUL so on but for
ARM programming, some extra instructions added such
as ADCNES and SWINE, etc.
EX: 1. ORG 0000h
MOV r1, #10
MOV r2, #15
ADD r3, r2, r1 // r3=r2+r1 and the final value stored in
r3 register//
2.ORG 0000h
MOV r1, #10
MOV r2, #15
SUB r3, r2, r1 // r3=r2-r1 and the final value stored in
r3 register//
[17]
The ARM Coretex-M3 Microcontroller Embedded
C Level Programming:
WAP to toggle the single LED through Embedded C
language using ARM cortex microcontroller.
#include “stm32f10x_gpio.h”
#include “stm32f10x_rcc.h”
GPIO_InitTypeDef GPIO_InitStructure;
int i;
#define LED_PORT GPIOB
Void binky();
Void main()
{
Void binky();
}
void binky(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPI
OB, ENABLE); //enable the PORTB pins//
GPIO_InitStructure.GPIO_Speed =
GPIO_Speed_50MHz; //set the port frequency//
GPIO_InitStructure.GPIO_Mode =
GPIO_Mode_Out_PP; //set the PORTB in output//
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All ;
//enabled all PORTB pins//
GPIO_Init(GPIOB, &GPIO_InitStructure); //initialize
the PORTB pins//
[18]
while(1){
GPIO_WriteBit(LED_PORT,GPIO_Pin_8,Bit_SET);
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_8,Bit_RESET)
;
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_9,Bit_SET);
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_9,Bit_RESET)
;
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_10,Bit_SET);
for (i=0;i<1000000;i++);
GPIO_WriteBit(LED_PORT,GPIO_Pin_10,Bit_RESE
T);
for (i=0;i<1000000;i++);
}
}
*********
[20]