Professional Documents
Culture Documents
1 Unit Es Printed
1 Unit Es Printed
UNIT – 1
7. Low Power RISC- MSP 430 : Introduction & Variants of MSP 430 family ------ 12
8. MSP430F2013 - Block diagram & features --------------------------------------------- 18
9. Memory map of MSP430 -------------------------------------------------------------------- 20
10. MSP430 –CPU architecture & registers -------------------------------------------------- 23
11. Addressing modes of MSP430 ------------------------------------------------------------ 28
12. Instruction formats & Instruction Timings of MSP430 ----------------------------- 31
13. Instruction set of MSP430 ------------------------------------------------------------------ 33
14. Sample Embedded system on MSP430 -------------------------------------------------- 39
1.1. Definition :
• An embedded system is an electronic/electro-mechanical system designed to perform a
specific function and is combination of both hardware and firmware (software). The
program instructions written for embedded systems are referred to as firmware, and are
stored in Read-Only-Memory or Flash memory.
• Every ES is unique, and the hardware as well as software is highly specialized to the
application domain. Embedded systems are designed to do some specific task, rather than
be a general purpose computer for multiple tasks.
(a) Operational Quality Attributes : These are related to the embedded system when it is in
the operational mode (or) online mode.
1. Response
2. Throughput
3. Reliability
4. Maintainability
5. Security
6. Safety
(b) Non-Operational Quality Attributes: These attributes are addressed for the product.
1. Testability and Debug ability
2. Evolvability – can be modified to take advantage of new technology
3. Portability
4. Time to prototype and market
5. Per Unit & Total cost
The embedded systems are used in various domains. Within the domain itself, according to
the application, they may have different functionalities. Each embedded system is designed to
serve the purpose of any one or a combination of the following tasks:
1. First generation(1G):
Built around 8-bit microprocessors like 8085, Z80 and 4-bit microcontrollers.
Simple in hardware circuit with firmware developed in Assembly code.
Examples: Digital telephone keypads, stepper motor control units
2. Second generation(2G):
Built around 16-bit μp and 8-bit μc.
They are more complex & powerful than 1G μp & μc.
Examples: Data Acquisition system (DAS), Supervisory Control and Data
Acquisition systems (SCADA)
3. Third generation(3G):
Built around 32-bit μp & 16-bit μc.
A new concept of application and domain specific processors / controllers like
Digital Signal Processors(DSPs), Application Specific Integrated Circuits(ASICs).
Examples: Robotics, Media, Industrial process control, networking, etc.
4. Fourth generation:
Built around 64-bit μp & 32-bit μc.
The concept of System on Chips (SoC), reconfigurable processors, multi-core
processors
High performance, tight integration, miniaturization, and very powerful.
Examples: Smart Phones, Mobile Internet Devices
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.
Example: an electronic toy
2. Medium-scale:
Slightly complex in hardware and firmware requirement.
Built around medium performance and low cost 16 or 32 bit μp/μc.
Usually contain embedded operating system ( either general purpose / RTOS) for
functioning
Examples: Industrial machines.
3. Large-scale:
Highly complex hardware & firmware.
Built around 32 or 64 bit RISC μp/μc or PLDs or SoC or multi-core processors.
Response is time-critical.
Examples: Mission critical applications.
Common user interface input devices : Keyboards, push button, switches, etc.
Common user interface output devices : LEDs, LCD, Buzzers…etc
Note that it is not necessary that all ES should incorporate these I/O user interfaces. It
depends on the type of application in which the ES is designed. For ex., if the ES is designed for
any handheld application such as a mobile handset, the system should contain user interfaces like
keyboard, display unit, speakers, microphone etc. Some Embedded Systems do not require any
manual intervention for their operation. They automatically sense the variations in the input
parameters using sensors which are connected to the input port, and the processor performs some
pre-defined operations with the help of firmware embedded in the system and sends some
actuating signals to the actuators connected to the output port of the Embedded system.
Sensors connected to the input port to sense/detect the changes in the input variables
converts input variables into electrical signals for any measurements/ control purpose
The memory of the system is responsible for holding the control algorithm and other
important configuration details. Memory for implementing the code may be present on the
processor or may be implemented as a separate chip interfacing the processor. In a controller
based embedded system, the controller may contain internal memory for storing code.
Embedded systems are domain and application specific and are built around a central core.
The core of the embedded system falls into any of the following categories:
Almost 80% of the embedded systems are processor/ controller based. The processor may be
microprocessor or a microcontroller or digital signal processor, depending on the domain and
application. Most of the ES in industrial control and monitoring applications make use of the
commonly available microprocessors and microcontrollers whereas domains which require signal
processing such as speech coding, speech recognition..etc make use of special kind of digital signal
processors supplied by manufacturers like Analog Devices, Texas Instruments,..etc
Microprocessors
A microprocessor is a silicon chip representing a central processing unit (CPU), which is
capable of performing arithmetic and logic operations according to a pre-defined set of
instructions.
In general, the CPU contains ALU, Control Unit and working registers.
A microprocessor is a dependent unit and it requires the combination of other hardware
like memory, timers, interrupt controller and I/O ports, etc. for proper functioning.
Microprocessors are used in general purpose applications.
Microcontrollers
A microcontroller is an integrated chip that contains CPU, data and program memory (
RAM and ROM), special and general purpose registers, Timers, Interrupt control unit and
dedicated I/O ports.
Since a microcontroller contains all the necessary functional blocks for independent
working, they found greater place in embedded domain.
Microcontrollers are application oriented and used in domain-specific applications.
3. RISC Vs CISC :
RISC and CISC are the two common Instruction Set Architectures (ISA) available for processor
design.
RISC (Reduced Instruction Set Computer)) CISC (Complex Instruction Set Computer)
Supports few addressing modes for Supports many addressing modes for
2 memory access and data transfer memory access and data transfer
instructions. instructions.
Instructions take fixed amounts of time for Instructions take varying amounts of time
4
execution for execution
Instruction pipelining concept is not
Instruction pipelining works effectively
5 effectively works as different sizes and
and increases the execution speed.
different execution times of instructions.
Orthogonal instruction set (allows each Non-orthogonal set (all instructions are not
6 instruction to operate on any register and allowed to operate on any register and use
use any addressing mode.) any addressing mode.
More silicon usage since more additional
Less silicon usage and decoding logic is not
7 decoder logic is required to implement the
complex.
complex instruction decoding.
Because of large amount of different and
Because of the simple instructions, the
8 complex instructions, the design of compiler
design of compiler is easy.
is complex.
9 A larger number of registers are available. Limited no. of general purpose registers
Operations are performed on registers only. Operations are performed either on registers
10
Memory operations are load and store only. or memory depending on instruction.
Can be Harvard or Von-Neumann
11 With Harvard Architecture.
Architecture.
Programmer needs to write more code to The programmer can achieve the desired
12 execute a task since instructions are simpler functionality with a single instruction.
ones. ( large code sizes) (small code sizes)
I/O devices are mapped into the system I/O devices are mapped into a separate
memory map. i.e Common address space for address space. i.e., there is separate
memory and I/O ports (The I/O ports are address space for memory and I/O ports.
viewed as memory locations and are addressed
likewise)
The control signals used for memory operation Different control signals are used for
and I/O operation are same. memory and I/O operations.
2
M/IO = 1 for both Memory and I/O M/IO =1 for memory operation
operations M/IO =0 for I/O operation
6 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 Full address space can be used for
7 Memory, because some locations are allotted addressing Memory, because I/O
for I/O ports. locations are separated from memory.
The entire address bus must be fully decoded Less logic is needed to decode a discrete
8
for every device, which increases the cost address and therefore less cost
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 stored in memory at the lowest address and
the higher order data byte at the highest address.
For ex., 4 byte long integer Byte3, Byte2, Byte1, Byte0 will be stored in memory as follows:
Big-endian means the higher order data byte is stored in memory at the lowest and the
lower order data byte at the highest address.
For ex., 4 byte long integer Byte3, Byte2, Byte1, Byte0 will be stored in memory as follows:
Introduction :
1. The MSP430 microcontroller from Texas Instruments (TI) is a 16-bit RISC based Mixed
Signal Processor with Von-Neumann architecture, designed for low power and portable
applications.
3. It is extremely easy to put the device into a low-power mode. No special instruction is
needed: The mode is controlled by bits in the status register. The MSP430 is awakened by
an interrupt and returns automatically to its low-power mode after handling the interrupt.
4. The address and data buses are 16-bits wide and the registers in CPU are also 16-bits wide.
Hence the registers can be used for either data (or) addresses.
5. Since it has 16-bit address bus, it can address 64KB of memory (RAM/ROM/Flash/Reg).
The amount of on-chip memory varies for different families of MSP430.
6. A wide range of peripherals are available, many of which can run autonomously without
the CPU for most of the time.
7. Many portable devices include liquid crystal displays, which the MSP430 can drive
directly.
8. Some MSP430 devices are classed as application-specific standard products (ASSPs) and
contain specialized analog hardware for various types of measurements.
9. The MSP430 family consists of several devices featuring different sets of peripherals
targeted for various applications : Internal oscillator, Timer including PWM, WDT, Serial
communication interface (USART, I2C, SPI), ADC, DAC, Comparators, Multipliers,
Brownout reset circuitry, Op-Amps for signal conditioning, LCD driver, DMA, built-in
bootstrap loader (BSL) using UART such as RS232 or USB, JTAG interface.. etc.
Although there are variants in devices in the family, a MSP430 microcontroller can be
characterized by:
MSP430X :
There is a new extended version of original MSP430 architecture, called MSP430X, which can
address extra memory with other improvements as well.
If CPU is MSP430, it has 16-bit address bus and it can address 64 KB of memory
(0x0000 – 0xFFFF)
If the CPU is MSP430X, it has 20-bit address bus and it can address 1 MB of memory.
The bottom 64 KB of memory from 0x0000 to 0xFFFF is same way as in the original
MSP430. The additional memory from 0x10000 to 0xFFFFF, is available for additional
ROM. This allows larger programs and tables to be stored.
The letters MSP stand for mixed signal processor, which is a reminder that many
MSP 430 practical applications require analog inputs. MSP430 indicates the member of
the 430 MCU platforms.
The letter after MSP430 shows the type of memory.
F
F : flash memory, C : masked ROM
There is a second letter for ASSPs (Application Specific Standard Products) to
show the type of measurement for which they are intended.
G (optional)
E : for electricity (Energy meters), W : for water (flow meters), and
G : for signals that require gain stage (Medical), provided by Op-Amps.
It indicates the generation of the device
1 series : upto 8 MHz,
2 series : upto 16 MHz
4 3 series : Legacy OTP (one time programmable)
4 series : upto 16 MHz with w/LCD
5 series : upto 25 MHz
6 series : upto 25 MHz with w/LCD
QZW Package (Ball Grid Array/ Pin Grid Array/ Dual In-line Package)
Tape and Reel
R (optional) T = Small Reel (7 –in)
R = Large Reel (11 –in)
MSP430x1xx :
MSP430x1xx Provides a wide range of general-purpose devices from simple versions to complete
systems for processing signals. There is a broad selection of peripherals and some include a
hardware multiplier, which can be used as a basic digital signal processor.
Flash- or ROM-based low-power MCUs
8 MHz Clock, 1.8–3.6 V operation
Power specification overview, as low as:
0.1 μA RAM retention
0.7 μA real-time clock mode
200 μA / MIPS active
Features fast wake-up from standby mode in less than 6 µs.
Device parameters
Flash/ROM options: 1–60 KB
RAM options: 128 B– 2 KB
GPIO options: 14/22/48 pins
ADC options: Slope, 10 & 12-bit SAR
Other integrated peripherals: 12-bit DAC, up to 2 16-bit timers, WDT, brown-out reset,
SVS, USART module (UART, SPI), DMA, 16×16 multiplier, Comparator_A, Temp. sensor
MSP430F2xx :
The MSP430F2xx Series are similar to the '1xx generation, but operate at even lower power,
support up to 16 MHz operation, double the speed of earlier devices, while consuming only half
the current at the same speed. It has On-chip clock (VLO) that makes it easier to operate without
an external crystal. Pull-up or pull-down resistors are provided on the inputs to reduce the
number of external components needed. Some come in 14-pin package with PDIP option, which is
attractive for anybody who has to build circuits by hand.
Flash- or ROM-based low-power MCUs
16 MHz Clock, 1.8–3.6 V operation
Power specification overview, as low as:
0.1 μA RAM retention
0.3 μA standby mode (VLO)
0.7 μA real-time clock mode
220 μA / MIPS active
Feature ultra-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: 10/16/24/32/48 pins
ADC options: Slope, 10 & 12-bit SAR, 16 & 24-bit Sigma Delta
Other integrated peripherals: operational amplifiers, 12-bit DAC, up to 2 16-bit timers,
watchdog timer, brown-out reset, SVS, USI module (I²C, SPI), USCI module, DMA, 16×16
multiplier, Comparator_A+, Temperature sensor
MSP430x3xx :
The MSP430x3xx Series is the oldest generation, designed for portable instrumentation with an
embedded LCD controller. This also includes a frequency-locked loop oscillator that can
automatically synchronize to a low-speed (32 kHz) crystal.
This generation does not support EEPROM memory, only mask ROM and UV- eraseable and one-
time programmable EPROM.
UV erasable and One Time Programmable ROM
16 MHz Clock, 2.5 – 5.5 V operation
Power specification overview, as low as:
0.1 μA RAM retention
0.9 μA real-time clock mode
160 μA / MIPS active
Features fast wake-up from standby mode in less than 6 µs.
Device parameters:
ROM options: 2–32 KB
RAM options: 512 B–1 KB
GPIO options: 14/40 pins
ADC options: Slope, 14-bit SAR
Other integrated peripherals: LCD controller, multiplier
MSP430x4xx :
MSP430x4xx series can drive LCDs with up to 160 segments. Many of them are ASSPs, but there
are general-purpose devices as well. These devices are used for low power metering and medical
applications.
Flash- or ROM-based ultra-low-power MCUs
16 MHz Clock, 1.8–3.6 V operation
FLL and SVS
Power specification overview, as low as:
0.1 μA RAM retention
0.7 μA real-time clock mode
200 μA / MIPS active
Features fast wake-up from standby mode in less than 6 µs.
Device parameters:
Flash/ROM options: 4 KB– 60 KB
RAM options: 256 B – 8 KB
GPIO options: 14/32/48/56/68/72/80 pins
ADC options: Slope, 10 & 12-bit SAR, 16-bit Sigma Delta
Other integrated peripherals: 12-bit DAC, Op Amps, RTC, up to two 16-bit timers,
watchdog timer, basic timer, brown-out reset, SVS, USART module (UART, SPI), USCI
module, LCD Controller, DMA, 16×16 & 32x32 multiplier, Comparator_A, Temp. sensor
MSP430x5xx series :
The MSP430x5xx Series are able to run up to 25 MHz, have up to 512 KB flash memory and up to
66 KB RAM. Includes an innovative power management module for optimal power consumption
and integrated USB.
MSP430x6xx series
The MSP430x6xx Series are able to run up to 25 MHz, have up to 512 KB flash memory and up to
66 KB RAM. It includes an innovative power management module for optimal power
consumption and integrated USB.
The MSP430 microcontroller from Texas Instruments (TI) is a 16-bit RISC based Mixed
Signal Processor with Von-Neumann architecture, designed for low power and portable
applications.
It is extremely easy to put the device into a low-power mode. No special instruction is
needed: The mode is controlled by bits in the status register. The MSP430 is awakened by
an interrupt and returns automatically to its low-power mode after handling the interrupt.
The address and data buses are 16-bits wide and the registers in CPU are also 16-bits wide.
Hence the registers can be used for either data (or) addresses.
The functional block diagram of the MSP430 F2003/F2013 consists of the following blocks :
On the left is the 16-bit CPU and its supporting hardware, including the clock generator.
The emulation, JTAG interface and Spy-Bi-Wire are used to communicate with a desktop
computer when downloading a program and for debugging.
The main blocks are linked by the memory address bus (MAB) and memory data bus (MDB).
It has flash memory, 1KB in the F2003 or 2KB in the F2013, and 128 bytes of RAM.
Six blocks are shown for peripheral functions (there are many more in larger devices).
Input/output ports, Timer_A, and a watchdog timer, Universal serial interface (USI) and
sigma–delta analog-to-digital converter (SD16_A) are particular features of this device.
The brownout protection comes into action if the supply voltage drops to a dangerous
level. Most devices include this but not some of the MSP430x1xx family.
There are ground and power supply connections. Ground is labeled VSS and is taken to
define 0V. The supply connection is VCC. For many years, the standard for logic was VCC
=+5V but most devices now work from lower voltages and a range of 1.8–3.6V is specified
for the F2013. The performance of the device depends on VCC. For ex., it is unable to
program the flash memory if VCC < 2.2V and the maximum clock frequency of 16MHz is
available only if VCC ≥ 3.3V.
The brownout reset circuit detects low supply voltages such as when a supply voltage is
applied to (or) removed from the VCC terminal. The brownout reset circuit resets the
device by triggering a POR (Power on Reset) signal when power is applied (or) removed.
The brownout circuit is used to provide the proper internal reset signal to the device
during power ON and power OFF.)
The Watchdog Timer (WDT) module restarts the system on occurrence of a software
problem (or) if a selected time interval expires. It is used to detect and recover from
computer malfunction.
During normal operation, the system regularly restarts the watchdog timer to prevent it
from elapsing, or "timing out". If the system fails to restart the watchdog due to a hardware
fault or program error,, the timer will elapse and generate a timeout signal. The timeout
signal is used to initiate corrective actions like placing the system in a safe state and
restoring normal system operation. Remember that the watchdog is active by default and
must either be disabled or regularly cleared before it rolls over. The WDT can also be used
to generate timely interrupts for an application.
The Supply Voltage Supervisor (SVS) is used to monitor the supply voltage or an external
voltage. The SVS can be configured to set a flag or generate a POR reset when the supply
voltage or external voltage drops below a user selected threshold.
The MSP430 von-Neumann architecture has address space shared with special function registers
(SFRs), peripherals, RAM, and Flash/ROM memory. The following shows the memory map of the
F2013. Most MSP430 devices have a similar memory map, differing only in the size of the regions
for RAM and ROM.
Peripheral registers with byte access and peripheral registers with word access:
Provide the main communication between the CPU and peripherals. Some must be accessed as
words and others as bytes. They are grouped in this way to avoid wasting addresses.
The address space from 010h to 0FFh is reserved for 8-bit peripheral modules. These modules
should be accessed with byte instructions.
The address space from 0x0100 to 0x01FF is reserved for 16-bit peripheral modules. These
modules should be accessed with word instructions.
Flash memory may be written one byte or word at a time, but must be erased in segments. The
information memory is divided into 2 segments (of 128-bytes each) in 4xx devices, and 4 segments
(of 64 bytes each) in 2xx devices. Segment A contains factory calibration data for the DCO in the
MSP430F2xx family and is protected by default.
The range of addresses has been extended from 64KB to 1MB in the MSP430X. This means
that addresses require 20 bits rather than 16 and the MAB is therefore 20- bits wider. The bottom
64KB of memory from 0x00000 to 0x0FFFF is laid out in exactly the same way as in the original
MSP430. The additional memory, from 0x10000 to 0xFFFFF, is available for additional ROM. This
permits larger programs and tables to be stored.
The above figure shows - Bits, Bytes, and Words in a Byte-Organized Memory.
For all devices, each memory location is formed by 1 data byte. The CPU is capable of
addressing data values either as bytes (8 bits) or words (16 bits).
Bytes are located at even or odd addresses.
Words are always addressed at an even address, which contain the least significant byte,
followed by the next odd address, which contains the most significant byte.
For 8-bit operations, the data can be accessed from either odd or even addresses, but for 16-bit
operations, the data values can only be accessed from even addresses.
For example, if a data word is located at address 0x0200, then the low byte of that data word is
located at address 0x0200, and the high byte of that word is located at address 0x0201.
This is called as Little-endian ordering, in which the low-order byte is stored at lower memory
address and high-order byte is at the higher address. For example, if a word contains the
hexadecimal value 0x1234. Its less significant (low-order) byte is 0x34 and it is stored at lower
memory address 0x0200 and the most significant (high-order) byte 0x12 is store at higher
memory address 0x0201.
The central processing unit (CPU) executes the instructions stored in memory. It steps
through the instructions in the sequence in which they are stored in memory until it encounters a
branch or when an exception occurs (interrupt or reset).
The CPU can run at a maximum clock frequency fMCLK of 16MHz in the MSP430F2xx family
and some newer MSP430x4xx devices, and 8MHz in the others. It is built using static logic, which
means that there is no minimum frequency of operation: The CPU can be stopped and will retain
its state until it is restarted. This is essential for low-power operation to be straightforward.
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
It used by subroutine calls to store the program counter value for return at the end of
subroutine (RET). When a subroutine is called, the CPU jumps to the subroutine, executes
the code there, then returns to the instruction after the call. It must therefore keep track of
the contents of the PC before jumping to the subroutine, so that it can return afterward.
This is the primary purpose of the stack.
It is used by interrupt - system stores the actual PC value first, then the actual status
register content on top of the stack. After servicing the interrupt, the system get the same
status as just before the interrupt happened by executing the instruction return from
interrupt (RETI).
It can be used by compiler for subroutine parameters
It can be used by user to store data for later use (store by PUSH, retrieve by POP).
The Status Register (SR/R2) stores the status bits and control bits.
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.
The CPUOFF, OSCOFF, SCG0, and SCG1 bits control the mode of operation of the MSP430MCU.
All systems are fully operational when all bits are clear. Setting combinations of these bits puts the
device into one of its 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 for DCO.
if DCO-CLK is not used for MCLK or SMCLK.
OSCOFF (Oscillator OFF ) : When set, turns off the VLO and LF XT1 crystal oscillator
if LFXT1-CLK is not used for MCLK or SMCLK.
CPUOFF : When set, turns off the MCLK, which stops the CPU.
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.
This is a very powerful feature, which allows the implementation of emulated instructions,
for example, instead of implementing a core instruction for an increment, the constant
generator is used.
The registers R2 and R3 can be used to generate six different constants commonly used in
programming, without the need to add an extra 16-bit word of code to the instruction.
The constants below are chosen based on the bit (As) of the instruction that selects the
addressing mode.
The assembler uses the constant generator automatically if one of the 6- constants is used
as an immediate source operand.
Registers R2 and R3, used in the constant mode, cannot be addressed explicitly; they act as
source-only registers.
The RISC instruction set of the MSP430 has only 27 instructions. However, the constant
generator allows the MSP430 assembler to support 24 additional, emulated instructions.
For example, the single-operand instruction
1. Register mode :
In this addressing mode, the data is available in any one of the registers in the CPU.
This is available for both source and destination
2. Indexed mode :
In this addressing mode, the address of data is the sum of constant base address and the
contents of a CPU register.
This mode is available for both source and destination
In this addressing mode, PC is used as the base address. So the address of data is the sum
of PC and relative offset address of data.
4. Absolute mode :
In this addressing mode, the absolute address of the data is available in the instruction.
This is already the complete address required, so that it should be added to a register that
contains ZERO. Hence, in indexed addressing, the Status Register is used as constant
generator (CG1) and it contains 0 when it is used as the base for indexed addressing.
Ex: mov.b &P1IN, R6 ; load byte from port address P1IN into R6
The above instruction moves the content of source address to the register R6
In this addressing mode, the address of the data is available in the register.
Indirect register addressing is shown by the symbol @ in front of a register such as @R5.
In other words, R5 is used as a pointer.
In this addressing mode, the address of the data is available in the register.
This addressing mode is shown by the symbol @ in front of a register with + sign after it
such as @R5+ . In other words, R5 is used as a pointer and it is automatically incremented
by 1 for BYTE operation and 2 by WORD operation.
Ex: mov.w @R5+, R6 ; load word from address (R5) into R6 and increment R5 by 2
7. Immediate mode :
In this addressing mode, the data is available immediately after the instruction.
The PC is automatically incremented after the instruction is fetched and therefore points to
the following word. Hence it is a special case of Indirect auto-increment register
addressing mode.
mov.b @PC+, R6 ;
The source and destination of an instruction are defined by the following fields:
src : The source operand defined by As and S-reg
dst : The destination operand defined by Ad and D-reg
As : Addressing bits responsible for the addressing mode used for the source (src)
Ad : Addressing mode used for the destination (dst)
S-reg : The working register used for the source (src)
D-reg : The working register used for the destination (dst)
B/W : Byte or word operation:
0: word operation 1: byte operation
All single-operand and dual-operand instructions can be byte or word instructions by using .B
or .W extensions. Byte instructions are used to access byte data (or) byte peripherals. Word
instructions are used to access word data (or) word peripherals. If no extension is used, the
instruction is a word instruction.
INSTRUCTION TIMINGS:
The number of CPU clock cycles required for an instruction depends on the instruction format
and the addressing modes used - not the instruction itself.
The number of clock cycles refers to the MCLK.
The number of MCLK cycles required for most instructions is limited by access to memory.
(i) It takes one cycle to fetch the instruction word itself. This is all if both source and
destination are in CPU registers.
Ex: mov.w R5, R6
(ii) One more cycle is needed to fetch the source if it is given indirectly as @Rn or @Rn+,
in which case the address is already in the CPU. This includes immediate data.
Ex: mov.w @R5, R6
(iii) Alternatively, two more cycles are needed if one of the indexed modes is used. The
first is to fetch the base address, which is added to the value in a CPU register to get
the address of the source. A second cycle is necessary to fetch the operand itself. This
includes absolute and symbolic modes.
Ex: mov.w 25(R5), R6
(iv) Two more cycle are needed to fetch the destination in the same way, if it is indexed.
Ex: mov.w @R5, 25(R6)
(v) A final cycle is needed to write the destination back to memory if required; no
allowance is needed for a register in the CPU.
The complete MSP430 instruction set consists of 27 core instructions & 24 emulated
instructions.
The core instructions are instructions that have unique op-codes decoded by the CPU.
The emulated instructions are instructions that make code easier to write and read, but do not
have op-codes themselves; instead they are replaced automatically by the assembler with an
equivalent core instruction.
For the emulated instructions, the operand is always a destination.
All these instructions are emulated, which means that the operand is always a destination
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
Invert destination
1 inv.w dst Performs bit-wise NOT operation (1’s complement) inv.w R6
dst ~dst
These instructions are used to set orclear the falgs in Status Register. All these instructions
are emulated instructions.
Instruction Operation Flag affected
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 )
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
The letters MSP stand for mixed signal processor, which is a reminder that many practical
applications require analog inputs. There is a selection of analog-to-digital converters with a
resolution of up to 16 bits. An example of a system where this choice is important is the weighing
machine shown in above Figure. It includes the following functional blocks:
The sensor has four resistive elements arranged as a Wheatstone bridge. Ideally, this is
balanced when there is no load, giving V+ = V− . Two of the resistances increase and two
decrease when a weight is placed on the scale pan, driving the bridge out of balance.
A differential amplifier magnifies the difference in voltage between its input terminals,
giving Vout = A(V+ −V−), where A is the gain.
The analog output of the amplifier is converted to a binary value by A/D converter.
The microcontroller multiplies the input by an appropriate factor so that the display gives
the weight in grams or ounces and subtracts an offset so that the display reads zero when
no weight is present. It also reads the buttons and supervises the complete system.
There is a serial interface between the microcontroller and the liquid crystal display, which
has a built-in controller.
This system clearly needs a lot of components, including several integrated circuits. In
contrast, the whole system can be constructed from a sensor, an MSP430F42x, a simple LCD
without a controller, and a couple of decoupling capacitors. The MSP430x4xx family drives
segmented LCDs directly, which eliminates the need for a controller. Several devices contain
ADCs with high-resolution, differential inputs, which would work directly from the sensor
without the need for an amplifier. The microcontroller can also manage the power drawn by the
circuit so that the processor would be switched off when it was not needed and the whole system
shut down after a period of inactivity.