AMC Unit-4 Notes - (14-10-22)
AMC Unit-4 Notes - (14-10-22)
AMC Unit-4 Notes - (14-10-22)
Page 1 of 26
2. List out the features and advantages of MSP430
Overview of MSP430 :
MSP430 family microcontrollers from Texas Instruments (TI), are designed for low cost, low
power and portable embedded applications
MSP430 has 16-bit RISC based processor architecture
It supports different Low power modes
It has 16 registers (R0-R15)
All registers are 16-bit wide
It has 16-bit Address bus and 16-bit data bus
Supports 27 core instructions, 24 emulated instructions and 7 addressing modes
It is capable of wake-up time below 1 microsecond
Extensive vectored-interrupt capability
A wide range of on-chip peripherals are available
Features of MSP430 :
Although there are variants in devices in the family, a MSP430 microcontroller can be
characterized by:
Device parameters
Flash/ ROM options : 1 KB – 60 KB
RAM options : 128 B– 8 KB
GPIO options : 14 - 80 pins
Clock and Power Specifications
CPU clock : 8/16/25 MHz
Operating voltage : 1.8–3.6 V
Active operation : 160 - 250 µA/MIPS
RTC mode operation : 0.7 µA
RAM retention : 0.1 μA
Fast wake-up from standby mode in less than 1 µs
Other integrated peripherals
(i) Basic Clock system
(ii) 10/12/16-bit ADC
(iii) I/O ports
(iv) 12-bit dual DAC
(v) Serial Port : SPI, I2C, UART
Page 2 of 26
(vi) Op-Amp
(vii) Timers
(viii) Comparator_A
(ix) WDT (Watch Dog Timer )
(x) Temp. sensor
(xi) RTC (Real Time Clock)
(xii) Multiplier
(xiii) DMA
(xiv) LCD driver
(xv) Supply Voltage Supervisor (SVS)
(xvi) Brown out Reset
(xvii) The emulator and JTAG interface
Advantages of MSP430 family :
16-bit RISC architecture
High-performance - High speed of execution
Low power consumption
Fast wake-up from standby mode in less than 1 µs
Variety of models with integrated memories, multiple programmable GPIO and Integrated
application-specific peripherals
Cost-effective
Applications of MSP430
Low power, hand-held smart devices
Test and measurement equipment
Smart Energy/Smart Grid solutions
Factory automation
Home and commercial site monitoring and control
Medical instrumentation
Fire and security
Intelligent lighting control
Transportation
Motion control
Automobiles
Gaming equipment
Page 3 of 26
3. Mention the Representation of MSP430 Part Numbering
Page 4 of 26
MSP430 family microcontrollers from Texas Instruments (TI), are designed for low cost, low
power and portable embedded applications
MSP430 has 16-bit RISC based processor architecture
It supports different Low power modes
It has 16 registers : R0-R15 All registers are 16-bit wide
It has 16-bit Address bus and 16-bit data bus
Supports 27 core instructions, 24 emulated instructions and 7 addressing modes It is capable of
wake-up time below 1 microsecond
Extensive vectored-interrupt capability
A wide range of on-chip peripherals are available
The functional block diagram of the MSP430 F2003/F2013 is shown in figure. The main blocks
are linked by the memory address bus (MAB) and memory data bus (MDB).
16-bit CPU:
It consists of 16-bit ALU, set of 16-registers (R0 – R15) and Logic needed to decode and execute the
instructions
The CPU has RISC architecture
Instructions processing on either bits, bytes or words
Supports 27 instructions and 7 addressing modes.
It can address the complete address range without paging
CPU clock : 16 MHz
Operating voltage : 1.8–3.6 V
Active operation : 200 µA/MIPS
RTC mode operation : 0.7 µA
RAM retention : 0.1 μA
Fast wake-up from standby mode in less than 1 µs
Basic Clock system:
The clock module provides the CLK for CPU and peripherals. Three clock signals are available
from the basic clock module:
MCLK : Master clock is used by CPU and system
SMCLK : Subsystem Master clock is distributed to high speed peripherals
ACLK : Auxiliary clock is also distributed to low speed peripherals
Page 5 of 26
The emulator and JTAG interface
The emulation, JTAG interface and Spy-Bi-Wire are used to communicate with a desktop computer
when downloading a program and for debugging.
Flash memory
Flash memory is used to store the programs and constant variables
The size of Flash memory in MSP430F2003 is 1 KB
The size of Flash memory in MSP430F2013 is 2 KB
RAM
RAM is used to store the temporary data (Read/Write memory)
The size of RAM in MSP430F2003 and F2013 is 128 Bytes
16-bit Sigma Delta ADC : SD16_A
The SD16_A is a high performance 16-bit analog to digital converter used to interface analog signals
with 200 KSPS
I/O ports : P1 & P2
The MSP430 has Two I/O ports: Port-P1 and Port-P2 The Port-P1 has 8- I/O pins and P2 has 2- I/O
pins. Each I/O pin is individually configurable for input (or) output. Each pin can be configurable for
pull-up / pull-down resistors Ports P1 and P2 have interrupt capability.
Watch Dog Timer
A watchdog timer (WDT) is an electronic timer that is used to detect and recover from computer
malfunctions. The WDT module restarts the system on occurrence of a software problem (or) if a
selected time interval expires. During normal operation, the system regularly restarts the WDT to
prevent it from elapsing, or "timing out". If the system fails to restart the WDT 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.
Timer_A2
Timers are essential to almost any embedded application
Timers are used to Generate fixed-period events, Periodic wakeup, Count edges, Generate delays,
Measure time intervals, Replacing delay loops with timer calls allows CPU to sleep, consuming less
power Timers can support multiple capture/compares, PWM outputs, interval timing and extensive
interrupt capabilities
Page 6 of 26
Universal Serial Interface (USI):
The Universal Serial Interface (USI) module supports multiple serial communication modes
UART : Asynchronous, Full duplex
SPI : Serial Peripheral Interface - Synchronous,
Full duplexI2C : Serial Peripheral Interface -Synchronous, Half duplex
Brown out Reset
The brownout protection comes into action if the supply voltage drops to a dangerous level
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 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.
Page 7 of 26
Special Function Registers:
The SFRs are located in the lower 16 bytes of the address space.
Some peripheral functions are configured in the SFRs for enabling and signaling
interrupts from peripherals.
Peripheral registers
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 0x0010 to 0x00FF is reserved for 8-bit peripheral modules.
The address space from 0x0100 to 0x01FF is reserved for 16-bit peripheral modules.
Random Access Memory:
RAM is used for storing the data variables.
RAM always starts at address 0x0200 and the end address of RAM depends on the
amount of RAM present on the device.
The F2013 has 128 Bytes of RAM.
Bootstrap loader (Flash devices only) :
The MSP430 flash devices contain an address space for boot memory, located between
addresses 0xC00 through to 0x0FFF.
The “bootstrap loader” can be used to program the flash memory in addition to the JTAG.
This memory region is not accessible by other applications, so it cannot be
overwrittenaccidentally.
Information memory (Flash devices only) :
A 256 B block of flash memory that is intended for storage of nonvolatile data.
This might include serial numbers to identify equipment, an address for a network, (or)
variables that should be retained even when power is removed. For example, a
printer might remember the settings from when it was last used and keep a count of the
total number of pages printed.
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 (each 128-bytes) in 4xx devices,
and 4 segments (each 64 bytes) in 2xx devices.
Page 8 of 26
Flash/ROM /Code memory:
It is used to store the program, including the executable code itself and any constant data.
The start address of Flash/ROM depends on the amount of Flash/ROM present on the
device. The end address for Flash/ROM is 0x0FFFF for devices with less that 60KB of
Flash/ROM.
The F2013 has 2 KB but the F2003 only 1KB flash memory
Interrupt and Reset Vectors:
Used to handle “exceptions,” when normal operation of the processor is
interrupted orwhen the device is reset.
The interrupt vector table is mapped into the upper 16 words of Flash/ROM address
space, with the highest priority interrupt vector at the highest Flash/ROM word address
(0x0FFFE).
The central processing unit (CPU) fetches the instructions from memory and executes the
instructions. The CPU can run at a maximum clock frequency fMCLK of 16MHz.
Page 9 of 26
The dedicated registers are
R0 : Program Counter [PC]
R1 : Stack Pointer [SP]
R2 : Status Register [SR]
R2/R3 : Constant Generator Registers [CG1/CG2]
The General–Purpose Registers (R4 to R15 ) :
These are used to store data values, address pointers, or index values andcan be
accessed with byte or word instructions.
Page 10 of 26
R0: Program Counter (PC) :
The 16-bit Program Counter (PC/R0) points to the next instruction to be fetched
frommemory and executed by the CPU.
It is important to remember that the PC is aligned at even addresses, because the
instructions are composed of 1-3 words. Hence the LSB of PC is hard-wired to 0.
The Program counter is incremented by the number of bytes used by the instruction
(2, 4, or6 bytes, always even).
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, the stack is allocated at the top of the RAM and
grows down towards low addresses.
The LSB of the stack pointer is hardwired to 0 in the MSP430, which guarantees
that it always points to valid words.
The purpose of the stack :
It used by subroutine calls - to store the Return address (PC value)
It is used by interrupt – to store the Return address (PC value) and
Status information (SR)
It can be used by compiler for subroutine parameters
It can be used by user to store data for later use by using PUSH and POP
instructions.
Page 11 of 26
(b) pop dst : This instruction is used to move the content of stack top to the destination
During the execution of ‘pop’ instruction, first the content of stack top is movedto the destination and
SP is incremented by 2
dst @ SP
SP SP+2
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
Page 12 of 26
R2: Status Register (SR)
The Status Register (SR/R2) stores the status bits and control bits.
Page 13 of 26
R2/R3: Constant Generator Registers (CG1/CG2)
The registers R2 and R3 are the constant generator registers, which can be used to generate
6-commonly used constants, depends on source addressing mode (As).
Register Addressing mode for Source operand (As) Constant
R3 Register 0
R3 Indexed +1
R3 Register Indirect +2
R3 Indirect with Auto increment -1 (FFFF)
R2 Register Indirect +4
R2 Indirect with Auto increment +8
Page 14 of 26
7. Describe the addressing modes of MSP430
Instruction is a command given to the processor to perform a specific operation on specified data.
Every instruction has 2- parts
Page 15 of 26
Ex: mov.b 3(R5), R6 ; load byte from address (3+R5) into R6
If R5 = 0004 then, the content of memory address 0007 is moved to R6
5. Absolute mode :
In this addressing mode, the absolute address of the data is available in the instruction.
Page 16 of 26
There are 3- core instruction formats of MSP430
Page 17 of 26
Instruction Set of MSP430
The complete MSP430 instruction set consists of 27 core instructions and 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.
Page 18 of 26
(2) Arithmetic instructions
(a) Binary Arithmetic Instructions with Two operands
Instruction Operation Example
Add the content of source to destination
1 add.w src, dst dst dst + src add.w R5, R6
Add with carry
2 addc.w src, dst dst dst + (src + C) addc.w R5, R6
Add carry bit to the destination
3 adc.w dst dst dst + C adc.w R6
Subtract the content of source from destination
4 sub.w src, dst dst dst - src sub.w R5, R6
Subtract with borrow
5 subc.w src, dst dst dst –( src + C) subc.w R5, R6
Subtract borrow bit from the destination
6 sbc.w dst dst dst – C sbc.w R6
Compares source and destination.
Performs ( dst – src),
but Only flags are changed
If dst > src : C=0, Z=0
7 cmp.w src,dst cmp.w R5,R6
If dst < src : C=1, Z=0
If dst = src : C=0, Z=1
Page 19 of 26
(b) Arithmetic Instructions with One operand :
All these instructions are emulated, which means that the operand is always a destination
Instruction Operation Example
Clear destination clr.w R6
1 clr.w dst dst 0 R6 0
The content of destination is decremented by 1 dec.w R6
2 dec.w dst dst dst – 1 R6 R6 - 1
Double decrement
decd.w R6
The content of destination is decremented by 2
3 decd.w dst R6 R6 – 2
dst dst – 2
The content of destination is inccremented by 1 inc.w R6
4 inc.w dst dst dst + 1 R6 R6 + 1
Double increment
incd.w R6
The content of destination is inccremented by 2
5 incd.w dst R6 R6 + 2
dst dst + 2
Test ( compare with zero)
Performs ( dst – 0), but Only flags are changed
If dst > 0 : C=0, Z=0
6 tst.w dst If dst < 0 : C=1, Z=0 tsd.w R6
If dst = 0 : C=0, Z=1
Page 20 of 26
(3) Logic instructions
Page 21 of 26
(c) Byte manipulation
Instruction Operation Example
Swap upper and lower bytes
1 swpb dst The high and the low byte of the operand swpb R6
are exchanged
dst.15:8 ↔ dst.7:0
Extend sign of lower byte
The sign of the low byte of the operand is
2 sxt dst extended into the high byte sxt R6
dst. 15:8 dst.7
If dst.7 = 0: high byte = 00 H
afterwards If dst.7 = 1: high byte = FF
H afterwards
These instructions are used to set or clear the flags in Status Register. All
these instructions are emulated instructions.
Instruction Operation Example
1 clrc Clear Carry bit C=0
2 clrn Clear Negative bit N=0
3 clrz Clear Zero bit Z=0
4 setc Set Carry bit C=1
5 setn Set Negative bit N=1
6 setz Set Zero bit Z=1
7 dint Disable General Interrupts GIE = 0
8 eint Enable General Interrupts GIE = 1
Page 22 of 26
(4) Shift and Rotate instructions
Page 23 of 26
(5) Control Transfer instructions
Instruction Operation Example
1 br src Branch ( go to) PC src
SP SP-2
2 call src Call Subroutine @ SP PC
PC @ SP SP
3 ret Return from Subroutine SP+2
SR @ SP
4 reti Return from Interrupt SP SP+2
PC @ SP
SP SP+2
5 nop No operation
( consumes single cycle )
JUMP Instructions Condition
Jump to
1 jmp label Unconditional Jump specicifed location
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
Page 24 of 26
8 jl label Jump if less than (signed values) Jump if (N xor V) =1
Page 25 of 26
Page 26 of 26