Unit - I: Introduction To Embedded Systems
Unit - I: Introduction To Embedded Systems
Unit - I: Introduction To Embedded Systems
Large, modern microprocessors need huge heat sinks and fans and
can draw over 100A of current.
Instruction decoder and other logic to control the CPU, handle resets, and
interrupts, and so on.
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.
This is a safety feature, which resets the processor if the program becomes
stuck in an infinite loop
Communication interfaces:
• These are needed in applications that must track the time of day.
Clocks are obvious examples but data loggers are also an important
case. development.
• These are used to download the program into the MCU and
communicate with a desktop computer during development.
Memory
Volatile and Nonvolatile Memory
Volatile: Loses its contents when power is removed. It is usually called
random-access memory or RAM.
The memory is usually static RAM, which means that it retains its data even
if the clock is stopped.
Nonvolatile: Retains its contents when power is removed and is used for
the program and constant data ROM
There are many types of nonvolatile memory
Masked ROM:
The data are encoded into one of the masks used for photolithography
and written into the IC during manufacture.
This memory really is read-only. It is used for the high-volume
production of stable products, because any change to the data
requires a new mask to be produced at great expense.
Some MSP430 devices can be ordered with ROM, shown by a C in their
part number. An example is the MSP430CG4619.
Harvard Architecture
Many microcontrollers use this architecture, including Microchip
PICs, the Intel 8051 and descendents, and the ARM9. The principal
advantage is efficiency.
It allows simultaneous access to the program and data memories.
For instance, the CPU can read an operand from the data memory at
the same time as it reads the next instruction from the program
memory.
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 cannot be read in the same way as volatile values from
the data memory.
von Neumann Architecture
Machine code:
The binary data that the processor itself understands. Each instruction
has a binary value called an opcode. It is unrecognizable to humans, unless
you spent a very long time on low-level debugging.
Assembly language:
The instructions are written as words called mnemonics rather than binary
values and a program called an assembler translates the mnemonics into
machine code.
C:
A compiler translates C into machine code that the CPU can
process.
C++:
An object-oriented language that is widely used for larger
devices.
Embedded C++ is a subset of the language intended for
embedded systems.
Java is another object-oriented language, but it is interpreted
rather than compiled and needs a much more powerful processor.
BASIC:
BASIC language is extended with special instructions to drive
the peripherals.
Disadvantages are the code often runs very slowly and the
hardware is expensive if it includes an interpreter.
MSP430
The MSP microcontrollers (MCUs) from Texas Instruments (TI) are
16-bit and 32-bit RISC-based, mixed signal processors designed for
ultra-low power applications.
MSP430 device features a powerful 16-bit RISC CPU, 16-bit
registers.
The architecture includes five low-power modes is optimized to
achieve extended battery life in portable measurement applications.
The digitally controlled oscillator (DCO) allows wake-up from low-
power modes to active mode in less than 1second.
The MSP430 instruction set consists of 27 core instructions that
make it easy to program in assembler or in C, and provide exceptional
flexibility and functionality.
The processors include low-cost sensor systems that capture analog
signals, convert them to digital values, and then process the data for
display or for transmission to a host system.
MSP430G2553
Ultra-low-power mixed signal microcontrollers with built-in
1. 16-bit timers; up to 24 I/O capacitive touch enabled pins;
2. Versatile analog comparator
3. Built-in communication capability using the universal serial
communication interface.
4. 10-bit Analogto-Digital Converter (ADC).
MSP430 Pin-out
• VCC and VSS are the supply voltage and ground for the whole device
• P1.0–P1.7, P2.6, and P2.7 are for digital input and output, grouped into ports P1
and P2.
• TACLK, TA0, and TA1 are associated with Timer_A; TACLK can be used as the clock
input to the timer, while TA0 and TA1 can be either inputs or outputs.
• A0−, A0+, and so on, up to A4±, are inputs to the analog-to-digital converter. It has
four differential channels, each of which has negative and positive inputs. VREF is
the reference voltage for the converter.
• ACLK and SMCLK are outputs for the microcontroller’s clock signals.
• SCLK, SDO, and SCL are used for the universal serial interface, which communicates
with external devices using the serial peripheral interface (SPI) or inter-integrated
circuit (I2 C) bus.
• XIN and XOUT are the connections for a crystal, which can be used to provide an
accurate, stable clock frequency.
• RST is an active low reset signal. Active low means that it remains high near VCC for
normal operation and is brought low near VSS to reset the chip.
• NMI is the nonmaskable interrupt input, which allows an external signal to interrupt
the normal operation of the program.
• • TCK, TMS, TCLK, TDI, TDO, and TEST form the full JTAG interface, used to program
and debug the device.
• SBWTDIO and SBWTCK provide the Spy-Bi-Wire interface, an alternative to the usual
JTAG connection that saves pins.
Functional Block Diagram
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
Memory Map
Information memory:
• A 256 B block of flash memory
that is intended for storage of
nonvolatile data.
Code memory:
• Holds the program, including
the executable code itself and
any constant data. The F2013
has 2 KB 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.
Central Processing Unit
The central processing unit (CPU) executes the instructions stored in memory.
It includes the arithmetic logic unit (ALU), which performs computation, a set of 16
registers designated R0–R15
The CPU can run at a maximum clock frequency fMCLK of 16 MHz in the
MSP430F2xx family and some newer MSP430x4xx devices, and 8 MHz in the
others.
The CPU can be stopped and will retain its state until it is restarted
Program counter, PC: This contains the address of the next instruction to be executed.
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.
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
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.
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,
Memory-Mapped Input and Output
Simple digital input and output takes place through sets of pins on the package of
the integrated circuit called ports.
The F2013 has all pins of port P1 available, labeled P1.0–P1.7, but only pins P2.6
and P2.7 of port P2.
The ports simply appear to the CPU as particular memory registers called
peripheral registers.
Each port is associated with a byte and each bit corresponds to a pin on the
package. These registers can be read, written, and modified in almost the same
way as simple registers in RAM
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.
P1OUT: Writing sends the value to be driven onto the pin if it is configured as a
digital output.
P1DIR: A bit of 0 configures the pin as an input, which is the default. Writing a 1
switches the pin to become an output.
CLOCK GENERATOR
Clocks for microcontrollers is a crystal with a frequency of a few MHz
would be connected to two pins.
• A fast clock to drive the CPU, which can be started and stopped rapidly
to conserve energy but usually need not be particularly accurate.
• A slow clock that runs continuously to monitor real time, which must
use little power and may need to be accurate.
Several types of oscillator are used to generate the clock signal.
Crystal:
Accurate and stable . Crystals for microcontrollers run at either a high
frequency of a few MHz to drive the main bus or a low frequency of
32,768 Hz for a real-time clock.
Disadvantages
Crystals are expensive and delicate, the oscillator draws a relatively
large current at high frequency and need two capacitors.
Crystal oscillators also take a long time to start up and stabilize.
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 MSP430 consisting of Three internal clocks:
• Master clock, MCLK, is used by the CPU and a few peripherals.
• Subsystem master clock, SMCLK, is distributed to peripherals.
• Auxiliary clock, ACLK, is also distributed to peripherals.
SMCLK runs at the same frequency as MCLK, both in the megahertz
range.
ACLK is often derived from a watch crystal and runs at a much lower
frequency. Most peripherals can select their clock from either SMCLK or
ACLK.
MSP430x1xx and MSP430F2xx families:
• ACLK comes from a low-frequency crystal oscillator, typically at 32 KHz.
• Both MCLK and SMCLK are supplied by an internal digitally controlled
oscillator (DCO), which runs at about 0.8 MHz in the MSP430x1xx and 1.1
MHz in the MSP430F2xx.
ACLK requires an external crystal, which is supplied on most
demonstration boards but not TI’s basic development kits .
No crystal means no ACLK with most MSP430s.
MSP430F2xx family include an internal, very low-power,
low-frequency oscillator (VLO) that can be selected for ACLK if there is
no crystal.
Exceptions: Interrupts and Resets
Interrupts:
Generated by hardware (although they can be initiated by software)
and indicate that an event has occurred that needs an urgent
response.