Beruflich Dokumente
Kultur Dokumente
SYSTEMS
www.maheshelectronics.wordpress.com
www.maheshelectronics.wordpress.com
UNIT – 1
PART-A
1. Embedded Systems – Introduction (Definition, Applications and Classification)
2. Features and architecture considerations(ROM,RAM,TIMERS…)
3. RISC Vs. CISC
4. Von-Neumann & Harvard Architecture
5. Memory mapped I/O and Isolated I/O
6. Little-Endian and Big-Endian
PART-B
1. Low Power RISC- MSP 430 : Introduction & Variants of MSP 430 family
2. MSP430F2013 - Block diagram & features
3. Memory map of MSP430
4. MSP430 –CPU architecture & registers
5. Addressing modes of MSP430
6. Instruction formats & Instruction Timings of MSP430
7. Instruction set of MSP430
8. Sample Embedded system on MSP430
www.maheshelectronics.wordpress.com
INTRODUCTION TO EMBEDDED SYSTEMS
www.maheshelectronics.wordpress.com
INTRODUCTION TO EMBEDDED SYSTEMS
www.maheshelectronics.wordpress.com
INTRODUCTION TO EMBEDDED SYSTEMS
• Applications of Embedded Systems
• Household appliances
Medical
• Automotive industry Automotive
• Home automation & security systems
• Telecom
• Computer peripherals Communications
• Computer networking systems Military
• Healthcare
• Banking & Retail
• Card Readers
• Measurements & Instrumentation
• Missiles and Satellites Comsumer Industrial
• Robotics
• Motor control systems
• Entertainment systems
• Signal & Image processing
www.maheshelectronics.wordpress.com
INTRODUCTION TO EMBEDDED SYSTEMS
• Classification of Embedded Systems:
• The classification of embedded system is based on
following criteria's:
• On generation
• On complexity & performance
www.maheshelectronics.wordpress.com
INTRODUCTION TO EMBEDDED SYSTEMS
• Classification based on generation
• 1. First generation(1G):8-bit μp and 4-bit μc.
www.maheshelectronics.wordpress.com
INTRODUCTION TO EMBEDDED SYSTEMS
• Classification based on Complexity and
performance
1. Small-scale
• Simple applications where the performance requirements are not time-critical.
• Built around low performance and low cost 8 or 16 bit μp/μc.
2. Medium-scale
• Slightly complex in hardware and firmware requirement.
• Built around medium performance and low cost 16 or 32 bit μp/μc.
3. Large-scale
• Highly complex hardware & firmware.
www.maheshelectronics.wordpress.com
Features and architecture considerations
• Basic elements of an embedded system:
www.maheshelectronics.wordpress.com
Features and architecture considerations
• System core:-Central processing unit
This include:
• Arithmetic logic unit (ALU), which performs
computation.
• Registers needed for the basic operation of the
CPU, such as the program counter (PC), stack
pointer (SP), and status register (SR).
• Further registers to hold temporary results.
• Instruction decoder and other logic to control the
CPU, handle resets, and interrupts, and so on.
www.maheshelectronics.wordpress.com
Features and architecture considerations
• Memory for the program: Non-volatile (read-only
memory, ROM), meaning that it retains its contents
when power is removed.
• Memory for data: Known as random-access memory
(RAM) and usually volatile.
• Input and output ports: To provide digital
communication with the outside world.
• Address and data buses: To link these subsystems to
transfer data and instructions.
• Clock: To keep the whole system synchronized. It may
be generated internally or obtained from a crystal or
external source; modern MCUs offer considerable
choice of clocks.
www.maheshelectronics.wordpress.com
Features and architecture considerations
Common peripherals:-
• Timers: Most microcontrollers have at least one
timer because of the wide range of functions that
they provide.
• They provide a regular “tick” that can be used to
schedule tasks in a program. Many programs are
awakened periodically by the timer to perform
some action—measure the temperature and
transmit it to a base station, for example—then go
to sleep (enter a low-power mode) until awakened
again. This conserves power, which is vital in
battery-powered applications.
www.maheshelectronics.wordpress.com
Features and architecture considerations
• Watchdog timer: This is a safety feature, which
resets the processor if the program becomes stuck
in an infinite loop.
• Communication interfaces: A wide choice of
interfaces is available to exchange information with
another IC or system. They include serial peripheral
interface (SPI), inter-integrated circuit (I²C or IIC),
asynchronous (such as RS-232), universal serial bus
(USB), controller area network (CAN), ethernet, and
many others.
www.maheshelectronics.wordpress.com
Features and architecture considerations
• Non-volatile memory for data: This is used to store
data whose value must be retained when power is
removed. Serial numbers for identification and
network addresses are two obvious candidates.
• Analog-to-digital converter: This is very common
because so many quantities in the real world vary
continuously.
www.maheshelectronics.wordpress.com
Features and architecture considerations
• Digital-to-analog converter: This is much less
common, because most analog outputs can be
simulated using PWM. An important exception used
to be sound, but even here, the use of PWM is
growing in what are called class D amplifiers.
• Real-time clock: These are needed in applications
that must track the time of day. Clocks are obvious
examples but data loggers are also an important
case.
www.maheshelectronics.wordpress.com
Features and architecture considerations
• Monitor, background debugger, and embedded
emulator: These are used to download the program
into the MCU and communicate with a desktop
computer during development.
• The processor communicates with these peripherals by
reading from, and writing to, particular addresses in
memory. These memory locations are called special
function registers or peripheral registers to distinguish
them from ordinary memories, which simply store
data, but exactly the same commands are used—no
special commands are needed. In practice,
microcontrollers spend much of their time handling the
peripheral registers.
www.maheshelectronics.wordpress.com
Features and architecture considerations
• RISC Vs CISC :
RISC (Reduced Instruction Set Computer)) CISC (Complex Instruction Set Computer)
Supports few addressing modes for memory access and data transfer Supports many addressing modes for memory access and data transfer
instructions. instructions.
Instructions take fixed amounts of time for execution Instructions take varying amounts of time for execution
Instruction pipelining works effectively and increases the execution Instruction pipelining concept is not effectively works as different sizes and
speed. different execution times of instructions.
Orthogonal instruction set (allows each instruction to operate on any Non-orthogonal set (all instructions are not allowed to operate on any
register and use any addressing mode.) register and use any addressing mode.
A larger number of registers are available. Limited no. of general purpose registers
www.maheshelectronics.wordpress.com
Features and architecture considerations
• HARVARD ARCHITECTURE Vs VON-NEUMANN ARCHITECTURE :
It has separate buses for instruction as It shares single common bus for instruction
well as data fetching. This means that, and data fetching. This means that only one
the data memory and program memory set of addresses covers both data memory
are separated. and program memory. The memory map
shows the addresses at which each type of
memory is located.
www.maheshelectronics.wordpress.com
Low performance as compared to Harvard
Easier to pipeline, so high performance can be achieve. architecture
First fetches the instruction and then fetches the data. The two separate fetches
It allows simultaneous access to the program and data memories. For instance, the CPU
slows down the controller’s operation.
can read an operand from the data memory at the same time as it reads the next
Because several memory cycles are needed to extract a full instruction from
instruction from the program memory.
memory, this architecture is intrinsically less efficient.
Since data memory and program memory are stored physically in different locations, no Accidental corruption of program memory may occur if data memory and
chances exist for accidental corruption of program memory program memory are stored physically in the same chip.
A problem with the Harvard architecture is that constant data (often lookup tables) must
be stored in the program memory because it is nonvolatile. This means that constants
The system is simpler and there is no difference between access to constant and
cannot be read in the same way as volatile values from the data memory. Special “table
variable data.
read” instructions must therefore be provided or part of the program memory is mapped
into data memory
Separate decoding logic is required, because separate buses and control signals are used No additional logic is required because, Same bus and control signals are used for
for accessing data memory and program memory accessing for both data memory and program memory.
www.maheshelectronics.wordpress.com
Features and architecture considerations
MEMORY MAPPED I/O & I/O MAPPED I/O :
Less no. of instructions are for I/O access. ( only IN and OUT
All instruction which can access memory can be used to access I/O instructions)
ports.
The data transfer takes place between Accumulator and I/O port
The data can be moved from any register to I/O port and vice-versa. only
The arithmetic, logic and bit manipulation instructions which are No instructions are available for direct manipulation of I/O data.
available for data in memory can also be used for I/O operations. First the processor reads data from I/O port and then
Hence the processor can directly manipulate data from I/O port. manipulates.
Large number of I/O devices can be interfaced Less no. of I/O devices can be interfaced
Full address space can’t be used for addressing Memory, because some Full address space can be used for addressing Memory, because
locations are allotted for I/O ports. I/O locations are separated from memory.
The entire address bus must be fully decoded for every device, which Less logic is needed to decode a discrete address and therefore
increases the cost less cost
www.maheshelectronics.wordpress.com
Features and architecture considerations
LITTLE-ENDIAN & BIG-ENDIAN PROCESSORS
Endianness specifies the order which the data is stored in the memory
by processor operations in a multi byte system.
Little-endian means lower order data byte is Big-endian means the higher order data
stored in memory at the lowest address and byte is stored in memory at the lowest and
the higher order data byte at the highest the lower order data byte at the highest
address. address.
2000H 2000H
2001H 2001H
2002H 2002H
2003H 2003H
www.maheshelectronics.wordpress.com
INTRODUCTION TO MSP430 MICROCONTROLLERS:
• MAIN CHARACTERISTICS OF MSP430 MICROCONTROLLER
• Flash (or) ROM-based low-power MCUs
• CPU clock : 8/16 MHz
• Operating voltage : 1.8–3.6 V
• Power specification overview, as low as:
• 0.1 μA RAM retention
• 0.7 μA real-time clock mode operation
• 160 - 250 µA/MIPS at active operation
• Fast wake-up from standby mode in less than 1 µs.
• Device parameters
– Flash/ ROM options: 1 KB – 60 KB
– RAM options: 128 B– 8 KB
– GPIO options: 14 - www.maheshelectronics.wordpress.com
80 pins
INTRODUCTION TO MSP430 MICROCONTROLLERS:
• Other integrated peripherals:
• 10/12/16-bit Analogue-to-Digital Converter (ADC);
• 12-bit dual Digital-to-Analogue Converter (DAC);
• Comparator-gated Timers;
• Watch Dog Timer
• SPI, I2C, UART
• Operational Amplifiers (OP Amps)
• 16×16 multiplier
• Comparator_A
• Temp. sensor
• LCD driver
• Supply Voltage Supervisor (SVS)
• Brown out Reset
• 16 bit RISC CPU:
• Instructions processing on either bits, bytes or words;
• Compact core design reduces power consumption and cost;
• Compiler efficient;
• 27 core instructions;
• 7 addressing modes;
• Extensive vectored-interruptwww.maheshelectronics.wordpress.com
capability.
BLOCK DIAGRAM OF MSP430 F2013/ F2003 MICROCONTROLLER
www.maheshelectronics.wordpress.com
MSP430 part numbering:
www.maheshelectronics.wordpress.com
VARIANTS OF MSP 430 FAMILY – 1XX, 2XX, 3XX, 4XX, 5XX:
0.1 μA RAM retention Flash/ROM options: 1–60 KB 12-bit DAC, up to 2 16-bit timers, WDT, brown-out reset, SVS,
MSP430x1xx
0.7 μA real-time clock mode RAM options: 128 B– 2 KB USART module (UART, SPI), DMA, 16×16 multiplier,
200 μA / MIPS active GPIO options: 14/22/48 pins Comparator_A, Temp. sensor
Features fast wake-up from standby mode in less than 6 µs. ADC options: Slope, 10 & 12-bit SAR
0.1 μA RAM retention Flash/ROM options: 1 KB–60 KB operational amplifiers, 12-bit DAC, up to 2 16-bit timers, watchdog
MSP430F2xx
0.3 μA standby mode (VLO) RAM options: 128 B – 8 KB timer, brown-out reset, SVS, USI module (I²C, SPI), USCI module,
0.7 μA real-time clock mode GPIO options: 10/16/24/32/48 pins DMA, 16×16 multiplier, Comparator_A+, Temperature sensor
220 μA / MIPS active ADC options: Slope, 10 & 12-bit SAR, 16 & 24-bit Sigma Delta
Feature ultra-fast wake-up from standby mode in less than 1 μs
0.1 μA RAM retention Flash/ROM options: 4 KB– 60 KB 12-bit DAC, Op Amps, RTC, up to two 16-bit timers, watchdog
MSP430x4xx
0.7 μA real-time clock mode RAM options: 256 B – 8 KB timer, basic timer, brown-out reset, SVS, USART module (UART,
200 μA / MIPS active GPIO options: 14/32/48/56/68/72/80 pins SPI), USCI module, LCD Controller, DMA, 16×16 & 32x32
Features fast wake-up from standby mode in less than 6 µs. ADC options: Slope, 10 & 12-bit SAR, 16-bit Sigma Delta multiplier, Comparator_A, Temp. sensor
0.1 μA RAM retention Flash options: up to 512 KB High resolution PWM, 5 V I/O's, USB, backup battery switch, up to
MSP430x5xx
2.5 μA real-time clock mode RAM options: up to 66 KB 4 16-bit timers, watchdog timer, Real-Time Clock, brown-out
165 μA / MIPS active ADC options: 10 & 12-bit SAR reset, SVS, USCI module, DMA, 32x32 multiplier, Comp B,
Features fast wake-up from standby mode in less than 5 µs. GPIO options: 29/31/47/48/63/67/74/87 pins temperature sensor
0.1 μA RAM retention Flash options: up to 512 KB USB, LCD, DAC, Comparator_B, DMA, 32x32 multiplier, power
MSP430x6xx
2.5 μA real-time clock mode RAM options: up to 66 KB management module (BOR, SVS, SVM, LDO), watchdog timer, RTC,
165 μA / MIPS active ADC options: 10 & 12-bit SAR Temp sensor
Features fast wake-up from standby mode in less than 5 µs. GPIO options: 74/90 pins
www.maheshelectronics.wordpress.com
Memory map of MSP430
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
• The cpu features
– Calculated branching
– Table processing
– 27 RISC instructions
– 7 addressing modes
– All instructions use all the addressing modes
– Full register access
– Single cycle register operations (RISC)
– Direct memory-to-memory transfers
– Constant generator provides most used values
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
There are 16 registers
Contents are 16-bits
User has access to all
registers
4 registers are special
purpose
Note bus structure
MDB – Memory Data
Bus
MAB – Memory Address
Bus
Also have 2 internal
bussed to deliver 2
operand to ALU
Diagram is called the datapath
of the processor
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
• R4 thru R15
– Registers are indistinguishable
– Can be used as
• Data Registers
• Address Registers
• Index values
– Can be accessed with byte or word instructions
– There is Register-Byte operation and Byte-Register
operation – covered later
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
• R0: Program Counter (PC) :
• The 16-bit Program Counter (PC/R0) points to the
next instruction to be fetched from memory and
executed by the CPU.
• The Program counter is incremented by the number
of bytes used by the instruction (2, 4, or 6 bytes,
always even).
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
• R1: Stack Pointer (SP)
• The stack memory is a memory block where the
data is stored in LIFO manner.
• The Stack Pointer (SP/R1) holds the address of the
stack-top.
• In the MSP430, as in many other processors, the
stack is allocated at the top of the RAM and grows
down towards low addresses.
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
• Operation of the Stack :
The operation of the stack is illustrated in the
following figure. The specific addresses are for
MSO430F2013 with 128 Bytes of RAM are from
0x0200 to 0x027F. Hence, Before the execution, the
initially the value of SP = 0x0280
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
• R2: Status Register (SR)
• The Status Register (SR/R2) stores the status bits
and control bits.
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
• Enable Interrupts :: Setting the general interrupt
enable (GIE) bit enables maskable interrupts.
• Clearing the bit disables all maskable interrupts.
• There are also nonmaskable interrupts, which
cannot be disabled with GIE.
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
• Control of Low-Power Modes :
• SCG1 (System clock generator 1) : When set, turns
off the SMCLK.
• SCG0 (System clock generator 0) : When set, turns
off the DCO dc generator, if DCO-CLK is not used for
MCLK or SMCLK.
• OSCOFF (Oscillator OFF ) : When set, turns off the
LF XT1 crystal oscillator,
• if LFXT1-CLK is not used for MCLK or SMCLK.
• CPUOFF : When set, turns off the CPU.
www.maheshelectronics.wordpress.com
MSP430 –CPU architecture & registers
• R2/R3: Constant Generator Registers (CG1/CG2)
• Depending of the source-register addressing modes (As) value, six commonly used constants
can be generated without a code word or code memory access to retrieve them.
• The constants below are chosen based on the bit (As) of the instruction that selects the
addressing mode.
•
R2 10 +4
R2
11 +8
R3
00 0
R3
01 +1
R3
10 +2
R3
11 -1 (FFFF)
www.maheshelectronics.wordpress.com
MSP430 –Addressing modes
• MSP430 addressing modes
– Addressing mode – the way in which the operand(s) of
an instruction are accessed, i.e., the effective addresses
are calculated.
– 7 modes supported
• Register Mode – (Rn) – operands are in registers
• Immediate Mode – #N – The operand is part of the
instruction
–Instructions have format OPCODE #OPERAND
• Absolute Mode – &ADDR – The address of the
operand is given by the word following the opcode
–Instructions have format OPCODE &ADDRESS
www.maheshelectronics.wordpress.com
MSP430 –Addressing modes
• Remainder of addressing mode
– Indexed Mode – X(Rn) – (Rn+X) points to (is the address
of) the operand. The value X is the next word in the
instruction stream after the OPCODE.
– Symbolic Mode – ADDR – (PC+X) points to the operand.
X is the next word.
– Indirect Register Mode - @Rn – Rn is used as a pointer to
the operand.
– Indirect Autoincrement - @Rn+ - Rn is used as a pointer
to the operand. After access Rn is incremented by 1 for
.B instructions and by 2 for .W instructions
www.maheshelectronics.wordpress.com
INSTRUCTION FORMATS OF MSP430 :
• Each instruction has 2- parts:
• The task to be performed – called as Operation code
(Opcode)
• The data to be operated on – called as Operand.
• Instruction format:
OPCODE OPERAND
www.maheshelectronics.wordpress.com
Movement Instructions (Data Transfer)
Instruction Operation Example
2 push.w src ( first the SP is decremented by 2 and the source content is stored at stacktop) SP SP-2
@ --SP = src @ SP R5
www.maheshelectronics.wordpress.com
Arithmetic and Logic Instructions
Binary Arithmetic Instructions with Two operands
Instruction Operation Example
Double decrement
decd.w R6
3 decd.w dst The content of destination is decremented by 2
R6 R6 – 2
dst dst – 2
Double increment
incd.w R6
5 incd.w dst The content of destination is inccremented by 2
R6 R6 + 2
dst dst + 2
Perfroms the decimal addtion of destination and source with carry dadd.w R5, R6
1 dadd.w src, dst
dst dst + src + C R6 R6 + R5+C
Invert destination
dst ~dst
www.maheshelectronics.wordpress.com
Logic Instructions with Two operands
Instruction Operation Example
The source operand and the destination operand are logically ORed. The result is placed
4 bis.w src, dst bis.w R5, R6
into the destination. The source operand is not affected.
The inverted source operand and the destination operand are logically ANDed. The result
5 bic.w src, dst bic.w R5, R6
is placed into the destination. The source operand is not affected
www.maheshelectronics.wordpress.com
Operations on Bits in Status Register
These instructions are used to set or clear the flags in Status Register. All these
instructions are emulated instructions.
www.maheshelectronics.wordpress.com
Control Transfer Instructions
Instruction Description Operation
SP SP-2
2 call src Call Subroutine @ SP PC
PC src
PC @ SP
3 ret Return from Subroutine
SP SP+2
SR @ SP
Return from Interrupt SP SP+2
4 reti
PC @ SP
SP SP+2
No operation
5 nop
( consumes single cycle )
www.maheshelectronics.wordpress.com
JUMP Instructions
1 jmp label Unconditional Jump
3 jnc / jhs label Jump if not carry / Jump higher or same Jump if C =0
5 Jnz / jne label Jump if not zero / Jump if not equal Jump if Z =0
www.maheshelectronics.wordpress.com