microcontrollers. embedded electronic systems and microcontrollers small-scale integration: the 555...

22
Microcontrollers

Upload: brittany-newman

Post on 23-Dec-2015

238 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Microcontrollers

Page 3: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Electronic Dice Example

1st figure 7400 series logic ICs. A Moore state machine. 2nd figure An eight-pin microcontroller. The economy in components. The

microcontroller automatically switches off the LEDs after a few seconds and enters a low-power mode until the button is pressed again.

Page 4: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Systems

Application-specific integrated circuits (ASICs): Specially designed for a particular application as their name implies. They provide the best performance but are extremely expensive to design and test.

Field-programmable gate arrays (FPGAs) and programmable logic devices (PLDs): Essentially an array of gates and flip-flops, which can be connected by programming the device to produce the desired function.

Microcontrollers: These have nearly fixed hardware built around a central processing unit (CPU). The CPU controls a range of peripherals, which may provide both digital and analog functions such as timers and analog-to-digital converters.

Page 5: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Small Microcontrollers

A microprocessor needs many other components to support it. These include a (large) external memory and the other.

The trend was therefore to integrate as many functions as possible on to the same chip as the processor. This gave rise to the microcontroller (MCU or μC), which typically contains all of the functions needed to make a complete computer system, including memory.

Page 6: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Anatomy of a Typical Small Microcontroller

Central processing unit: 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).

Page 7: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Anatomy of a Typical Small Microcontroller

Registers to hold temporary results. Instruction decoder and other logic to control the CPU, handle

resets, and interrupts, and so on. Memory for the program: Nonvolatile (read-only memory, ROM). Memory for data: Known as random-access memory (RAM)

usually volatile. Input/output ports: To provide digital communication with the

outside world. Address and data buses: To link 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.

Page 8: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Anatomy of a Typical Small Microcontroller

The more common peripherals. Timers: Most microcontrollers have at least one timer.

The time at which transitions occur on an input can be recorded.

Outputs can be driven on/off automatically at a specified frequency.

They provide a regular “tick” that can be used to schedule tasks in a program. 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.

Nonvolatile 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.

Page 9: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Anatomy of a Typical Small Microcontroller

Analog-to-digital converter: This is very common because so many quantities in the real world vary continuously.

Digital-to-analog converter: This is much less common, because most analog outputs can be simulated using PWM.

Real-time clock: These are needed in applications that must track the time of day.

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.

Page 10: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Memory

Each location store 1 byte (8 bits or 1B) of data and is often called a register, although this term is sometimes reserved for memories within the CPU.

Memory is linked to the CPU by buses for data, address, and control. Buses are shared sets of wires that join several components.

The number of wires in a bus defines its width, which is the size of data that can be processed by the CPU.

For example, an 8-bit processor has a data bus of this width and most operations in its CPU use 8 bits. The address bus need not have the same width as the data bus and is often wider.

Addresses are always quoted in hexadecimal. Each hex digit is known as nibbles.

External memory can be added using a separate interface such as SPI.

Page 11: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Volatile and Nonvolatile Memory

Memory can be classified into two main varieties: Volatile: Loses its contents when power is removed. It is usually called

random-access memory or RAM. The vital feature is that data can be read or written with equal ease. The memory is usually static RAM.

Nonvolatile: Retains its contents when power is removed and is therefore used for the program and constant data. It is usually called read-only memory or ROM. Most modern microcontrollers can write to their nonvolatile memory but it is much slower and more complicated than writing to RAM.

Page 12: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Volatile and Nonvolatile Memory

There are many types of nonvolatile memory in use: Masked ROM: The data are encoded into one of the masks used

for photolithography and written into the IC during manufacture.

EPROM (electrically programmable ROM): As its name implies, it can be programmed electrically but not erased. Devices must be exposed to (UV) light for about ten minutes.

OTP (one-time programmable memory): This is just EPROM in a normal package without a window, which means that it cannot be erased.

Flash memory: This can be both programmed and erased electrically and is now by far the most common type of memory. The practical difference is that individual bytes of EEPROM can be erased but flash can be erased only in blocks.

Most MSP430 devices use flash memory, shown by an F in the part number.

Page 13: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Harvard and von Neumann Architectures

General-purpose processors use almost exclusively the von Neumann architecture but both are used in microcontrollers.

Harvard Architecture The volatile (data) and nonvolatile (program) memories are treated as

separate systems Many microcontrollers use this architecture, including Microchip PICs, the Intel

8051 and the ARM9. It allows simultaneous access to the program and data memories. The 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. Special “table read” instructions must be provided.

Von Neumann Architecture There is only a single memory system in the von Neumann or Princeton

architecture. Only one set of addresses covers both the volatile and nonvolatile memories. Several memory cycles may be needed to extract a full instruction from

memory. The system is simpler and there is no difference between access to constant

and variable data. Microcontrollers with a von Neumann architecture include the MSP430, the

Freescale HCS08, and the ARM7.

Page 14: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Harvard and von Neumann Architectures

Page 15: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Software

The CPU in a microcontroller spends much of its time interacting with peripherals, although it may have to perform some calculations on the values.

Several languages may be used for programming a small microcontroller:

Machine code: The binary data that the processor itself understands.

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: The most common choice for small microcontrollers nowadays. A compiler translates C into machine code that the CPU can process.

Page 16: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Where Does the MSP430 Fit?

The MSP430 was introduced in the late 1990s and it is the simplest microcontroller in TI’s current portfolio.

It is a particularly straightforward 16-bit processor with a von Neumann architecture, designed for low-power applications.

The CPU is often described as a reduced instruction set computer (RISC).

The address and data buses are 16 bits wide. The registers in the CPU are also all 16 bits wide and can be used

interchangeably for either data or addresses. This makes the MSP430 simpler than an 8-bit processor with 16-bit addresses.

The MSP430 fits between traditional 8- and 16-bit processors. The 16-bit data bus and registers clearly define it as a 16-bit processor. It can address only 216 = 64KB of memory.

Page 17: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Where Does the MSP430 Fit?

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.

There is a wide choice of clocks. The MSP430 can wake from a standby mode rapidly, perform its tasks, and return to a low-power mode.

A wide range of peripherals is available, many of which can run autonomously without the CPU for most of the time.

Page 18: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Where Does the MSP430 Fit?

The MSP430 can restart quickly because of its DCO, which may be an important factor in the overall power budget.

Currently four families of MSP430 are available. The letter after MSP430 shows the type of memory. Most part

numbers include F for flash memory but some have C for ROM. There is a second letter to show the type of measurement for which

they are intended: E for electricity, W for water, and G for signals that require a gain stage, provided by operational amplifiers.

The next digit shows the family and the final two or three digits identify the specific device.

Page 19: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Where Does the MSP430 Fit?

MSP430x1xx: It can be used as a digital signal processor. Packages have 20–64 pins.

MSP430F2xx: Introduced in 2005. Its CPU can run at 16 MHz. Some come in 14-pin packages, including a traditional plastic dual-in-line (PDIP) option. Pull-up or pull-down resistors are provided on the inputs to reduce the number of external components needed. There are many options for analog inputs. Even the smallest, 14-pin devices offer a 16-bit sigma–delta ADC.

MSP430x3xx: The original family, which includes drivers for LCDs. It is now obsolescent.

MSP430x4xx: Can drive LCDs with up to 160 segments. Many of them are ASSPs (application-specific standard product), but there are general-purpose devices as well. Their packages have 48–113 pins, many of which are needed for the LCD.

MSP430X: The original MSP430 architecture. It can address extra memory. Curiously, this is not marketed as a separate family: The devices are included

in the MSP430F2xx and MSP430F4xx families with nothing in their part number to

distinguish them. The CPU is a MSP430x if there is more than 64KB of memory.

Page 20: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Where Does the MSP430 Fit?

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.

The analog output of the amplifier is converted to a binary value in an analog-to-digital converter.

Page 21: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

Weighing machine with a liquid crystal display, broken down into individual functions

The whole system can be constructed from a sensor, an MSP430, a simple LCD without a controller, and a couple of decoupling capacitors.

Page 22: Microcontrollers. Embedded Electronic Systems and Microcontrollers Small-Scale Integration: The 555 Medium-Scale Integration: 4000 Series CMOS Large-Scale

MSP430