444_micro.pdf

13
Microprocessor/Microcontroller Microprocessor/Microcontroller Architecture Asst. Prof. Suree Pumrin, Ph.D. Semester 2/2553 1 2102444 Introduction to Embedded Systems Lecture material taken from: ¾ “The 80x86 IBM PC and Compatible Computers (Volumes I&II): Assembly language, Design and Interfacing,” 4 th ed., Mazidi, M.A. d M idi JG P ti H ll 2003 and Mazidi, J.G., Prentice Hall, 2003. ¾ “Principles and Applications of Electrical Engineering,” 5 th ed., Rizzoni, G., McGraw Hill, 2007. Rizzoni, G., McGraw Hill, 2007. “Digital Systems Principles and Applications,” 10 th edition, Ronald J. Tocci, Neal S. Widmer, and Gregory L. Moss, Prentice Hall, 2006. 2 2102444 Introduction to Embedded Systems Objectives Describe what make microprocessors work Explain the difference in microprocessors, microcontroller, and microcomputer Identify CISC vs RISC Explain the difference in von Neumann and Harvard architecture State the purpose of analog-to-digital conversion State the purpose of Digital-to-Analog conversion Describe the sampling process. 3 2102444 Introduction to Embedded Systems Topics • Introduction Microprocessor Systems Overview Inside the computer Inside the computer Digital-to-Analog converter (DAC)/Analog-to- Di it l t (ADC) Digital converter (ADC) Sample-and-Hold operation Microcontroller Systems Overview 4 2102444 Introduction to Embedded Systems

Upload: hl5udv

Post on 01-Jan-2016

10 views

Category:

Documents


0 download

DESCRIPTION

222

TRANSCRIPT

Page 1: 444_Micro.pdf

Microprocessor/MicrocontrollerMicroprocessor/Microcontroller Architecture

Asst. Prof. Suree Pumrin, Ph.D.Semester 2/2553Se este / 553

12102444 Introduction to Embedded Systems

Lecture material taken from:“The 80x86 IBM PC and Compatible Computers (Volumes I&II): Assembly language, Design and Interfacing,” 4th ed., Mazidi, M.A.

d M idi J G P ti H ll 2003and Mazidi, J.G., Prentice Hall, 2003.“Principles and Applications of Electrical Engineering,” 5th ed., Rizzoni, G., McGraw Hill, 2007.Rizzoni, G., McGraw Hill, 2007.

• “Digital Systems Principles and Applications,” 10th edition, Ronald J. Tocci, Neal S. Widmer, and Gregory L. Moss, Prentice Hall, 2006.

22102444 Introduction to Embedded Systems

Objectives• Describe what make microprocessors work• Explain the difference in microprocessors, p p ,

microcontroller, and microcomputer• Identify CISC vs RISC y• Explain the difference in von Neumann and Harvard

architecture• State the purpose of analog-to-digital conversion• State the purpose of Digital-to-Analog conversion• Describe the sampling process.

32102444 Introduction to Embedded Systems

Topics

• Introduction• Microprocessor Systems Overview• Inside the computer• Inside the computer• Digital-to-Analog converter (DAC)/Analog-to-

Di it l t (ADC)Digital converter (ADC)• Sample-and-Hold operation• Microcontroller Systems Overview

42102444 Introduction to Embedded Systems

Page 2: 444_Micro.pdf

Microprocessor Systems Overview• Instruction set

Complex instruction set computers (CISC)Reduced instruction set computers (RISC)Reduced instruction set computers (RISC)

• Architecturevon Neumann architecture (a.k.a. Princeton architecture)Harvard architecture

• Basic computer systemCentral processing unit (CPU) – Registers, Arithmetic Logic Unit (ALU), control unitMemory – program & dataInput and Output (I/O) systemPeripherals – Analog to digital converter, timer unit, serial

i ti i t f tcommunications interface, etc.Data path – address bus, data bus, control bus

52102444 Introduction to Embedded Systems

CISC vs RISC• Complex instruction set computer (CISC), e.g., x86,

680x0Typical PC architectureTypical PC architectureMany operations, some of them very complex

• Reduced instruction set computer (RISC) e g PIC• Reduced instruction set computer (RISC), e.g., PIC, ARM, SPARC

Simpler instructions can be executed at higher speedSC f fRISC is common used in workstations for higher performance

Pentium is a combination of CISC and RISC.

• Modern CISCs implemented as RISCs internally• Only the total system performance matters

62102444 Introduction to Embedded Systems

von Neumann Architecture (I)

72102444 Introduction to Embedded Systems

von Neumann Architecture (II)

• Memory stores programs and dataMemory stores programs and data• Central processing unit (CPU) fetches

d tand execute• Input/output unit interface with input and p p p

output devices, e.g., printer, disk, CRT, keyboardkeyboard

82102444 Introduction to Embedded Systems

Page 3: 444_Micro.pdf

Harvard Architecture

92102444 Introduction to Embedded Systems

N (P i t )von Neumann (Princeton) vs Harvard

• Data and instructions mixed in the same P i t hit tmemory: Princeton architecture

• Data and instructions in separate memory: Harvard architecture

• Princeton architecture simpler to implementp p• Most DSPs use Harvard architecture for

streaming datastreaming data

102102444 Introduction to Embedded Systems

Microprocessors (I)Microprocessors (I)

A i i l l di it l i t t d i it d iA microprocessor is a large-scale digital integrated circuit device that can be programmed with a series of instructions to perform specified functions on data.

A single microprocessor can perform computations and send signals from many different sensors measuring different parameters to many different display, storage, or control devices, under control of a single software programof a single software program.

112102444 Introduction to Embedded Systems

Mi (II)Microprocessors (II)

T i ll t l• Typically external program memory• Range from devices with few thousand

transistors to 5-10 million transistors• To implement complete computer must still p p p

include input/output subsystems, memory, etc.• The components connected via system busThe components connected via system bus• Intel: x86 family, 8088, 80286, …, Pentium

Zilog Z80• Zilog: Z80• Motorola: 680x0 family

122102444 Introduction to Embedded Systems

Page 4: 444_Micro.pdf

Microprocessor Data Types (I)Microprocessor Data Types (I)

• Signed and unsigned binary integersSigned and unsigned binary integers• Binary coded decimal (BCD)• American Standard Code for Information

Interchange (ASCII)g ( )• Floating-point numbers

132102444 Introduction to Embedded Systems

Microprocessor Data Types (II)Microprocessor Data Types (II)

• Unsigned binary integers8 bit unsigned binary integer : 00 FF (0 255)8-bit unsigned binary integer : 0016 – FF16 (0 -255)

• Signed binary integersT ’ l t fTwo’s complement form

8-bit signed number: FF16 = -116 bit i d b bit 15 t th i16-bit signed number: bit 15 represents the sign

• BCD4 bits: 00002 – 10012 (0 – 9)

142102444 Introduction to Embedded Systems

Microprocessor Data Types (III)Microprocessor Data Types (III)

• ASCII7-bit code represents alphanumeric (alpha characters7 bit code represents alphanumeric (alpha characters and numbers) and special symbols

• Floating-pointFloating point Three components: sign, exponent, and mantissaExample: 4 5x10-2Example: -4.5x10 2

Sign = 1 (negative), Exponent = -2, and Significant (mantissa) = 4.5

Normalize: 1.XXXX x 2n : 10 = 10102sign = 0 (positive), normalize binary number = 1.010x 23

152102444 Introduction to Embedded Systems

Some Important TerminologySome Important Terminology

bit 0nibble 0000byte 0000 0000word 0000 0000 0000 0000kilobyte 210 = 1024 byteskilobyte 2 = 1024 bytesmegabyte 220 = 1,048,576 bytes

i b 230 1 billi bgigabyte 230 > 1 billion bytesterabyte 240 > 1 trillion bytes

162102444 Introduction to Embedded Systems

Page 5: 444_Micro.pdf

MicrocomputersMicrocomputers

• Similar to microcontroller but used as part of a larger embedded system

• Complete computer• Implemented using microprocessorImplemented using microprocessor• Typically constructed utilizing numerous

integrated circuitsintegrated circuits• Complexity varies: simple microcomputer can be

i l t d i l hi ith li it d b dimplemented on single chip with limited onboard memory, simple I/O system

172102444 Introduction to Embedded Systems

Internal Organization of ComputersInternal Organization of Computers

CPU ( t l i it) R i t• CPU (central processing unit): Registers, Arithmetic Logic Unit (ALU), control unit

Execute (process) information stored in memoryExecute (process) information stored in memory• Memory

Store program and datap g• I/O devices

Provide means of communicating with CPU• Data path (bus): address bus, data bus, control

busC i f ti f l t lCarry information from place to placeFor a device (memory or I/O) to be recognized by the CPU, it must be assigned an address.CPU, it must be assigned an address.

182102444 Introduction to Embedded Systems

Computer SystemComputer System

192102444 Introduction to Embedded Systems

Approximation of an analog signal

33

2

1

0

Quantization – The process of converting an analog value to a code. During the quantization process a binary code is assigned to each sampled value.

20

g p

2102444 Introduction to Embedded Systems

Page 6: 444_Micro.pdf

A/D and D/A

Most physical variables are analog. Any information that must be input to a digital system must first be put into digital form. Analog-to-digital (A/D) converter and digital-to-analog (D/A) converter are used to interface a computer to the analog world so that the computer can monitor and control a physical variable.

21

o to a d co t o a p ys ca a ab e

2102444 Introduction to Embedded Systems

DAC (1)

Digital-to-analog conversion (DAC) is a process of taking a value represented in digital code and converting it to a voltage or current that is proportional to the digital value

22

voltage or current that is proportional to the digital value.2102444 Introduction to

Embedded Systems

DAC (2)

232102444 Introduction to Embedded Systems

DAC (3)

Analog output = K x digital input,

K = Afs/(2N-1)

where K is a resolution (step size), Afs is the analog full-scale ( p ), fs goutput and N is the number of bits.

Percentage resolution:% resolution = (step size / full scale) x 100%

242102444 Introduction to Embedded Systems

Page 7: 444_Micro.pdf

DAC Example (1)

252102444 Introduction to Embedded Systems

DAC Example (2)A computer controls the speed of a motor. The 0-2 mA current is amplified to produce a motor speeds from 0-1000 rpm. How many bits should be used to produce a motor speed with error < 2 rpm?bits should be used to produce a motor speed with error < 2 rpm? The desired speed is 326 rpm, what is the actual speed?

step size = 1000/(29 – 1)

= 1.957 rpm

2N -1 > 1000/22N > 501N = 9 p

# of steps = 326/1.957

= 166.58 -> 167

Nmin = 9

166.58 167

Actual speed = 167 x 1.957

= 326 8 rpm26

= 326.8 rpm.2102444 Introduction to

Embedded Systems

DAC Specifications (1)

• Resolution (step size): A smallest amount by which the analog input must change to produce a change in digital outputinput must change to produce a change in digital output.

• Accuracy: Full scale error: the maximum deviation of the DAC’s output from its expected value, e.g., an accuracy of ± 0.01% F.S.p , g , y

Ex. F.S. output = 9.375 V± 0.01% x 9.375 V = ±0.9375 mV

This mean that the output of this DAC can be off by as much as 0.9375 mV from its expected value.Linearity error: the maximum deviation in step size from the ideal step size, e.g., a linearity error of ± 0.01% F.S.

Ex An expected step size is 0 625 V and F S output = 9 375 VEx. An expected step size is 0.625 V. and F.S. output = 9.375 V.This mean that the actual step size count be off by as much as 0.9375 mV.

272102444 Introduction to Embedded Systems

DAC Specifications (2)

• Offset error: A deviation from the ideal 0 V at the output of a DAC when the input is all 0s.

• Settling time: Time for the output of a DAC toSettling time: Time for the output of a DAC to go from 0 to full scale ±½ step size as all 0s inputs are changed into all 1s.inputs are changed into all 1s.

• Monotonicity: The ouput of a DAC increases as the binary input is increasedthe binary input is increased.

282102444 Introduction to Embedded Systems

Page 8: 444_Micro.pdf

Analog-to-Digital (A/D) Converter

Analog to Digital (A/D)Analog-to-Digital (A/D) Converter is a circuit that converts an analog input t di di it lto a corresponding digital output.

292102444 Introduction to Embedded Systems

ADC Specifications

• Quantization error: A difference between the actual (analog) quantity and the digital value assigned to it, e.g., ± LSB or ± ½ LSBg , g ,

• Conversion time, tc: it is a time interval between the end of the START pulse and the activation ofthe end of the START pulse and the activation of the end of conversion, (EOC), output.

t (max) = (2N - 1) clock cyclestc (max) (2 1) clock cyclestc (avg.) = tc(max)/2 ≈ 2N-1 clock cycle

302102444 Introduction to Embedded Systems

Sample-and-Hold Operation (1)

312102444 Introduction to Embedded Systems

Sample-and-Hold Operation (2)

• Sampling – The process of converting an analog signal into a series of impulses representing the amplitude of the signal at a given time.p p g p g g

• Hold – After the signal is sampled it is applied to a hold circuit.• Sampling frequency – should be at least twice the highest analog

freq encfrequency• Nyquist frequency – if the sampling rate is less than 2 times the

highest analog frequency and effect called aliasing where g g y gfrequencies are generated by the sampling process that cause interference problems

322102444 Introduction to Embedded Systems

Page 9: 444_Micro.pdf

ADC with Multiple Inputs

332102444 Introduction to Embedded Systems

Data AcquisitionData Acquisition

A i l d• A typical computer data acquisition system

• The computer initiates a new• The computer initiates a new conversion cycle by generating the START pulses.

• The end of conversion signal from the ADC is fed to the computercomputer.

• The computer monitors the end of conversion then it loads the digital data into memory.

342102444 Introduction to Embedded Systems

Random access memory (RAM)Random-access memory (RAM)

• Use for temporary storage data• Use for temporary storage data. It is a volatile Memory -- Memory requiring electrical power to keep information stored i e manypower to keep information stored, i.e., many semiconductor memories are volatile, all magnetic memories are non-volatile.

• Types of RAMStatic RAM (SRAM): Can store data as long as powerStatic RAM (SRAM): Can store data as long as power is applied.Dynamic RAM (DRAM): Data are stored on charged y a c ( ) ata a e sto ed o c a gedcapacitor. It is necessary to refresh data or recharge the capacitors regularly.

352102444 Introduction to Embedded Systems

R d O l M (ROM)Read-Only Memory (ROM)

• ROM is a logic circuit that holds information in storage in the form of binary numbers that cannot be altered but can be read by a logic circuit.

A ROM is an array of memory cells each of which can store either 1 or 0• A ROM is an array of memory cells, each of which can store either 1 or 0.

• The array consists of 2m x n cells, where n is the number of bits in each word stored in ROM and m is the number of address lines.word stored in ROM and m is the number of address lines.

362102444 Introduction to Embedded Systems

Page 10: 444_Micro.pdf

Types of ROMTypes of ROM

• Mask-Programmed ROMA mask is used to control the electrical interconnection on the chip. Need a high-volume applications.Can’t be reprogrammed.

• Programmable ROMs (PROMs)User-programmable.Once programmed, it can’t be reprogrammed.

• Erasable Programmable ROM (EPROM)g ( )Can be programmed and reprogrammed by the user.Can be erased by exposing it to ultraviolet (UV).

• Electrically Erasable PROM (EEPROM)Electrically Erasable PROM (EEPROM)Can be electrically programmed, erased, and reprogrammed.

372102444 Introduction to Embedded Systems

Various Types of Memories

382102444 Introduction to Embedded Systems

BusBus

• Data bus: a pathway between the CPU and its external devices

Bidirectional: CPU uses data bus either to receive or to send data.

• Address bus: identify the devices and memory connected to the CPU

Unidirectional: CPU uses the address bus only to send out addresses.F dd li th b f l ti hi hFor x address lines, the number of locations, which CPU can communicate, = 2x .

392102444 Introduction to Embedded Systems

Microcontroller (I)Microcontroller (I)

• A microcontroller is a special-purpose microprocessor-based system, designed to perform many functions.

402102444 Introduction to Embedded Systems

Page 11: 444_Micro.pdf

Microcontrollers (II)Microcontrollers (II)

• Includes microprocessor, I/O subsystems• Typically include peripherals, e.g., timers, serial

communications channels Analog to digital conversioncommunications channels, Analog to digital conversion, digital to analog conversion, direct memory access (DMA)

• Memory subsystem may or may not be included• Microcontroller = Microprocessor +

Memory + I/OMemory + I/O= Embedded microprocessor

• MCS-51 family (Intel, Dallas, 8032, 89C52, 8051,…), y ( , , , , , ),68HC11 family (Motorola)

412102444 Introduction to Embedded Systems

Internal Organization of MicrocontrollerInternal Organization of Microcontroller

Typically microcontroller includes microprocessor i/oincludes microprocessor, i/o subsystem, and peripherals such as timers, serial

i ti h lcommunications channels, analog to digital conversion, digital to analog conversion, and direct memory access (DMA).

422102444 Introduction to Embedded Systems

Automotive InstrumentationAutomotive Instrumentation

• In modern automotive instrumentation ainstrumentation, a microcontroller performs all the signal processing operations for severaloperations for several measurements.

• Depending on the p gtechnology used, the sensors’ outputs can be either digital or analog.either digital or analog.

432102444 Introduction to Embedded Systems

Sensor Interface

If the sensor signals are analog, they must be converted to digital format by means of an analog-to-digital converter (ADC).

442102444 Introduction to Embedded Systems

Page 12: 444_Micro.pdf

Interrupt Request• After the ADC conversion is completed, the ADC then signals the computer by changing the logic state on a separate line that sets its interrupt request.

• When an interrupt occurs, the processor automatically jumps to a designated program location and executes the interrupt service subroutine.subroutine.

452102444 Introduction to Embedded Systems

Microcontroller ApplicationMicrocontroller Application

Example: A typical automotive engine controller.

462102444 Introduction to Embedded Systems

An Automotive Engine ControllerAn Automotive Engine Controller

472102444 Introduction to Embedded Systems

General Description ofGeneral Description of An Automotive Engine Controller

• The controller consists of a processor section and an input/output section mounted in an enclosureinput/output section, mounted in an enclosure.

• A generic controller is programmed with different software for a wide range of production enginesoftware for a wide range of production engine applications.

• Specific hardware/software designs are provided forSpecific hardware/software designs are provided for each vehicle application.

• The controller is able to communicate with a personal pcomputer for software debugging and development.

482102444 Introduction to Embedded Systems

Page 13: 444_Micro.pdf

Exercise

1. What are the advantages in Harvard architecture?2 What’s the difference in a microprocessor a2. What s the difference in a microprocessor, a

microcomputer, and a microcontroller?3 Suppose it is desired to implement 4-Kbyte 16-bit3. Suppose it is desired to implement 4-Kbyte 16-bit

memory. a) How many bits are required for the memory address register? ) y q y gb) How many bits are required for the memory data register?

492102444 Introduction to Embedded Systems