Unit 01
Unit 01
ARCHITECTURE OF MSP430
Embedded Systems
• An embedded system is a combination of computer hardware and software designed for a
specific function. Embedded systems may also function within a larger system. The
systems can be programmable or have a fixed functionality. Industrial machines,
consumer electronics, agricultural and processing industry devices, automobiles, medical
equipment, cameras, digital watches, household appliances, airplanes, vending machines
and toys, as well as mobile devices, are possible locations for an embedded system.
Structure of embedded systems
Embedded systems vary in complexity but, generally, consist of three main elements:
• Hardware. The hardware of embedded systems is based around microprocessors and microcontrollers.
Microprocessors are very similar to microcontrollers and, typically, refer to a CPU (central processing
unit) that is integrated with other basic computing components such as memory chips and digital signal
processors (DSPs). Microcontrollers have those components built into one chip.
• Software and firmware. Software for embedded systems can vary in complexity. However, industrial-
grade microcontrollers and embedded IoT systems usually run very simple software that requires little
memory.
• Real-time operating system. These are not always included in embedded systems, especially smaller-
scale systems. RTOS es define how the system works by supervising the software and setting rules
during program execution.
A basic embedded system would consist of the following elements:
• This module consists of five low-power modes that increase battery life in portable
measurement applications.
• MSP430 has a feature of 16-bit registers, sixteen-bit RISC CPU and constant generators
which provides maximum code efficiency.
• The digitally controlled oscillator (DCO) of this module converts low power modes to
active mode in less than 6µs.
• The MSP430x11x series is an ultra-low power signal microcontrollers that consist of a 16-
bit timer and fourteen input and output pinouts.
These are the main features of MCP430,
• It is available in a 20 pin plastic small outline widebody package.
• Its operating voltage range is 2.5v to 5.5 v.
• Its active mode is 330 µA at 1 MHz, 3 V.
• Its stands by mode are 1.5 µA.
• It's off mode (Ram Retention) is 0.1 µA.
• This module is available in 16-bit architecture, 200ns instruction cycle time.
• This module consists of various internal resistors, single external resistor,32 kHz crystal,
high frequency, resonator and external clock source.
• It has a 16-bit timer with a three capture/compare registers.
• In this module, programme protection is done by a security fuse.
• It has serial onboard programming.
• This module has 16 kb flash, 512 B RAM, 10-bit ADC, two 16-bit timer
Introduction, MSP430
a. Powerful processing capability
• MSP430 series microcontroller is a 16-bit microcontroller, using a compact
instruction set (RISC) structure, with a rich addressing mode (7 source operand
addressing, 4 destination operand addressing), concise 27 kernel instructions, and a
large number of analog instructions; a large number of registers and on-chip data
memory can participate in a variety of operations; there is also a highly efficient
look-up table processing instructions. These features ensure that highly efficient
source programs can be produced.
b. Fast computing speed
• In terms of computing speed, the MSP430 series microcontroller can achieve 125ns
instruction cycle driven by 8MHz crystal. 16-bit data width, 125ns instruction cycle
and multi-function hardware multiplier (multiply and add) together, can achieve some
algorithms of digital signal processing (such as FFT, etc.)
c. More interrupt sources
• MSP430 series microcontroller has more interrupt sources and can be arbitrarily nested, flexible
and convenient to use. When the system is in a power-saving standby state, it only takes 6us to
wake it up with an interrupt request.
d. Ultra-low power consumption
• MSP430 microcontroller has ultra-low power consumption because of its unique features in
reducing the chip's supply voltage and flexible and controllable operating clock.
• First, the MSP430 series microcontroller power supply voltage is 1.8 ~ 3.6V voltage. Therefore,
it can run at MHz clock conditions. The chip current will be about 200 ~ 400uA, the clock off
mode of the lowest power consumption of 0.1uA.
• Second, the unique clock system design. In the MSP430 family, there are two different system
clock systems: the basic clock system and frequency-locked loop (FLL and FLL+) clock system
or DCO digital oscillator clock system. Some use one crystal oscillator (32768Hz) and some use
two crystal oscillators). The clocks required for each function are generated by the system clock
system. And these clocks can be turned on and off under the control of instructions, thus
enabling control of the overall power consumption.
e. Stable system operation
• After power-on reset, the CPU is first started by DCOCLK to ensure that the
program starts to execute from the correct position and that the crystal oscillator
has enough starting and stabilization time. Then the software can set the control
bits of the appropriate registers to determine the final system clock frequency. If
the crystal oscillator fails when used as the CPU clock MCLK, the DCO will
automatically start to ensure the system works properly; if the program runs away,
the watchdog can be used to reset it.
f. Rich on-chip peripheral modules
• Members of the MSP430 series microcontroller are integrated with rich on-chip
peripherals. They are watchdog (WDT), analog comparator A, timer A (TimerA),
timer B (TimerB), serial ports 0, 1 (USART0, 1), hardware multiplier, LCD driver,
l 0-bit/l 2-bit ADC, I2C, bus direct data access (DMA), port 0 (P0), ports 1 to 6
(P1 to P6), basic timer (Bas i c Timer) and some other peripheral modules in
different combinations.
g. Convenient and efficient development environment
• At present, the MSP430 series has three types of devices, OPT type(Optane type
memory), FLASH type, and ROM type. These devices have different development means.
For OPT type and ROM type devices are developed using emulators after the successful
burn-in or mask chip. FLASH type has a very convenient development and debugging
environment. Because the device has an on-chip JTAG(Joint Test Action Group) debug
interface and electrically erasable FLASH memory, we use the method of developing by
downloading the program to FLASH first, then controlling the operation of the program
through software in the device, and reading the information in the chip by the JTAG
interface for the designer to debug. This approach requires only a PC and a JTAG
debugger instead of an emulator and programmer.
h. Adapt to the industrial-grade operating environment
• MSP430 series devices are industrial-grade, operating environment temperature of
40 ~ +85 degrees Celsius. The products can be designed for use in industrial
environments.
Architecture of MSP430
Main characteristics of a MSP430 microcontroller
• These devices have 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). All MSP430s
include input/output ports, Timer_A, and a watchdog timer, although the details differ. The 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 example, it is unable to program the flash memory if VCC
Memory
Little-endian ordering: The low-order byte is stored at the lower address and the high-order byte at
the higher address. This is used by the MSP430 and is the more common format.
Big-endian ordering: The high-order byte is stored at the lower address. This is used by the
Freescale HCS08, for instance.
Memory Map
A brief description of each region
• Special function registers: Mostly concerned with enabling functions of some modules and
enabling and signaling interrupts from peripherals. 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. If the bytes and words were mixed, numerous unused bytes would be needed
to ensure that the words were correctly aligned on even addresses.
• Random access memory: Used for variables. This always starts at address 0x0200 and the upper
limit depends on the size of the RAM. The F2013 has 128B.
• Code memory: Holds the program, including the executable code itself and any constant data.
The F2013 has 2KB but the F2003 only 1KB.
• Interrupt and reset vectors: Used to handle “exceptions,” when normal operation of the
processor is interrupted or when the device is reset. This table was smaller and started at 0xFFE0
in earlier devices
• Bootstrap loader: Contains a program to communicate using a standard serial protocol, often with the COM
port of a PC. This can be used to program the chip but improvements in other methods of communication
have made it less important than in the past, particularly for development.
• Information memory:A256B 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, for instance—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. The information memory is laid
out with smaller segments of flash than the code memory, which makes it more convenient to erase and
rewrite.
Central Processing Unit
• 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).
• includes the arithmetic logic unit (ALU), which performs computation, a set of 16 registers
designated R0–R15 and the logic needed to decode the instructions and implement them.
• The CPU can run at a maximum clock frequency f MCLK 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.
Stack pointer, SP: 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. Some
processors use separate hardware for the stack but the MSP430 uses the top (high addresses) of the main
RAM. The stack pointer holds the address of the most recently added word and is automatically adjusted as
the stack grows downward in memory or shrinks upward
• Status register, SR: This contains a set of flags (single bits), whose functions fall into
three categories. The most commonly used flags are C, Z, N, and V, which give
information about the result of the last arithmetic or logical operation. The Z flag is set if
the result was zero and cleared if it was nonzero, for instance. Decisions that affect the
flow of control in the program can be made by testing these bits.
• Constant generator: This provides the six most frequently used values so that they need
not be fetched from memory whenever they are needed. It uses both R2 and R3 to provide
a range of useful values by exploiting the CPU’s addressing modes.
• General purpose registers: The remaining 12 registers, R4–R15, are general working
registers. They may be used for either data or addresses because both are 16-bit values,
which simplifies the operation significantly
Memory-Mapped Input and Output
• Port P1 input, P1IN: Reading returns the logical values on the inputs if they are
configured for digital input and output. This register is read-only. It is also volatile, which
means that it may change at a time that a program cannot predict. This is of course why
the input port is there, so that the MCU can react to its surroundings. You want to know
when a user presses a button, for instance. This is a reminder that P1IN is not just a
simple memory and that some care is needed when programming in C .
• Port P1 output, P1OUT: Writing sends the value to be driven onto the pin if it is
configured as a digital output. If the pin is not currently an output, the value is stored in a
buffer and appears on the pin if it is later switched to be an output.
• Port P1 direction, P1DIR:Abit of 0 configures the pin as an input, which is the default.
Writing a 1 switches the pin to become an output
Clock Generator
• Crystal: Accurate and stable. Crystals for microcontrollers typically run at either a high frequency of a few
MHz to drive the main bus or a low frequency of 32,768Hz for a real-time clock. The disadvantages are that
crystals are expensive and delicate, the oscillator draws a relatively large current, particularly at high
frequency, and the crystal is an extra component and may need two capacitors as well. Crystal oscillators also
take a long time to start up and stabilize, often around 105 cycles, which is an unavoidable side effect of their
high stability.
• Resistor and capacitor (RC): Cheap and quick to start but used to have poor accuracy and stability. The
components can be external but are now more likely to be integrated within the MCU. The quality of
integrated RC oscillators has improved dramatically in recent years and the F20xx provides four frequencies
calibrated at the factory to within ±1%.
1.Interrupts: Usually generated by hardware (although they can be initiated by software) and often indicate that an
event has occurred that needs an urgent response. A packet of data might have been received, for instance, and needs
to be processed before the next packet arrives. The processor stops what it was doing, stores enough information
(the contents of the program counter and status register) for it to resume later on and executes an interrupt service
routine (ISR). It returns to its previous activity when the ISR has been completed. Thus an ISR is something like a
subroutine called by hardware (at an unpredictable time) rather than software. A second use of interrupts, which is
particularly important in the MSP430, is to wake the processor from a low-power state.
2.Resets: Again usually generated by hardware, either when power is applied or when something catastrophic has
happened and normal operation cannot continue. This can happen accidentally if the watchdog timer has not been
disabled, which is easy to forget. A reset causes the device to (re)start from a well-defined state.