Professional Documents
Culture Documents
Number of unit: 3
Lecture: 33 Hours (64%)
Laboratory: 10 Hours (20%)
Tutorial: 4 Hours (8%)
Mini project: 4 Hours (8)
Reference Book:
•Muhammad Ali Mazidi, Rolin D. Mckinlay &
Danny Causey.
•PIC Microcontroller and Embedded Systems:
Using Assembly and C for PIC18, Pearson
Prentice Hall 2008.
1.0 Introduction to Microprocessor
1.1 History of Computer
1.2 Components of a Computer
1.3 History of Microprocessor
1.4 Microprocessor System
1.5 Microcontroller System
1.6 Embedded System
1.7 Embedded System Application
2
1.1 History Of Computer
22
von-Neumann Architecture
23
Harvard Architecture
26
Basic Computer Architecture
• Central Processing Unit
– Interprets and carries out all the instructions contained in
software
• Memory
– Used to store instructions and data
– Random Access Memory (RAM)
– Read Only Memory (ROM)
• Input/Output
– Used to communicate with the outside world
Buses
27
28
1.3 History Of Microprocessor
1950s - The beginning of the digital era and
electronic computing
1969 – Intel is a small startup company in Santa
Clara with 12 employees. Fairchild, Motorola
are large semiconductor companies; HP and
Busicom make calculators
1971 – Intel makes first microprocessor the 4-bit
4004 series for Busicom calculators
1972 – Intel makes the 8008 series, an 8-bit
microprocessor, ATARI is a startup company,
Creates a gaming console and releases PONG
29
1974 – the first real useful 8-bit microprocessor is
released by Intel – the 8080Motorola introduces
the 6800 series. Zilog has the Z80
1975 – GM and Ford begin to put microcontrollers
in cars. Many cars today have over 100
microcontrollers. TI gets into the microprocessor
business with calculators and digital watches
1977 – Apple II is released using MOS 6502
(similar to motorola 6800). Apple II dominated
from 1977 to 1983
1978 – Intel introduces the first 16-bit processor,
the 8086. Motorola follows with the 68000 which
is ultimately used in the first Apple Macintosh
30
1981 – IBM enters the PC making market and
uses the Intel 8088 – proliferation of the home
computer
1982-1985 – Intel introduces the 32-bit 80286
and 80386
1989 – 80486 is being used in PC’s, able to run
Microsoft Windows
1992 – Apple, IBM and Motorola begin to make
PowerMac and PowerPC’s using Motorola chips
1993 – Pentium chip is released
The rest is history
31
32
Microcontroller versus Microprocessor
33
34
Processor Performance
CPU Time
= # Cycles × Cycle Time
= # Instructions × CPI × Cycle Time
35
Microprocessor
• A single chip that contains a whole CPU
– Has the ability to fetch and execute instructions
stored in memory
– Has the ability to access external memory,
external I/O and other peripherals
• Examples:
– Intel P4 or AMD Athlon in desktops/notebooks
– ARM processor in Apple iPod
36
Microprocessor (MPU)
– Read instructions
– Process binary data
CPU Time
= # Cycles × Cycle Time
= # Instructions × CPI ×
Cycle Time
330_01 38
The CPU
• Purpose: The controlling element in a computer
system that performs data transfers, integer
arithmetic and logic, and input/output operations.
• Sizes: 4-bits to 64-bits
• Speeds: up to 4 GHz
• A byte is 8-bits
• Memory is addressed by byte
• RISC vs. CISC
39
CPU Task
• Executes instructions from the memory
system.
• A program is a collection of instructions stored
sequentially in the memory.
• A program is the computer’s software.
• The stored program concept makes the
computer fast and powerful.
40
Data Transfer Operations
• Most of a CPUs time is spent transferring data.
• Data transfers include: instruction fetches,
transfers between memory and registers,
transfers between registers and I/O.
• Transfers occur though the data bus.
41
Arithmetic and Logic Operations
• The CPU performs arithmetic on integers
using addition, subtraction, multiplication, and
division (some microcontrollers do not divide).
• Logic operations include AND, OR (inclusive and
exclusive), NOT, and shift/rotate.
42
Decisions
• The CPU makes decisions based upon numeric
facts to control the flow of a program.
• Zero—Not Zero, Positive—Negative, Carry—
No Carry
• Decisions modify the flow of a program
• Flow control allows tasks to be repeated or
skipped.
43
Memory
• Memory in a computer system is normally
numbered in bytes.
• Memory is accessed by bytes using a memory
address (address bus) numbered from memory
location 00000000.
• Memory addresses are expressed in the
hexadecimal numbering system (radix 16).
• Memory data flow through the data bus.
44
Data Bus
• The data bus is 4-, 8-, 16-, 32-, or 64-bits in
width in modern computers.
• The size of the CPU and its data bus are the
same or in some cases the data bus may be
twice as wide as the CPU size.
• A 16-bit computer has a 16-bit data bus.
• The Pentium 4 is a 32-bit computer with a 64-
bit data bus.
45
Address Bus
• The address bus selects a memory location or an I/O
device
• The size (number of bits) of the address bus
determines the maximum memory size.
• An 8-bit address can address 256 bytes of memory
(28).
• 1K = 1024 and requires a 10-bit address
• 1M = 1024 * 1024 and requires a 20-bit address
• 1G = 1M * 1024 and requires a 30-bit address
• 1T = 1G * 1024 and requires a 40-bit address
46
Control Bus
• The control bus controls memory and I/O.
• The control bus contains two main signals that
originate from the CPU.
• The #RD signal causes a read operation.
• The #WR signal causes a write operation.
• Some CPUs also contain a signal that selects
memory or I/O called M/#IO.
47
ROM
• A ROM is a nonvolatile memory that is used to
store programs and static data
• The ROM is usually either an EPROM or an
EEPROM memory.
• The EPROM is erased using an ultraviolet
lamp.
• The EEPROM is erased electrically
• In either device, memory does not change
when power is removed from the system.
48
RAM
• The RAM is the read/write memory in a system that
stored dynamic data and will not retain data without
power.
• RAM is available as either SRAM or DRAM.
• SRAM stores data as long as power is applied.
• DRAM must be refreshed because it only stores data
for a few milliseconds.
• Large memory system usually use DRAM and small
memory systems usually use SRAM.
49
I/O
• The I/O in a computer allows the CPU and its
program to communicate to humans and
machines.
• A input device inputs data to the CPU and
examples include keyboards and switches.
• An output device accepts data from the CPU
and examples include printers, indicators, and
so forth.
• I/O data is often 8-bits in width.
50
INSTRUCTION SET
51
Intel processors
• CPU Year Data Memory MIPS
• 4004 1971 4 1K
• 8008 1972 8 16K
• 8080 1974 8 64K
• 8088 1980 8 1M .33
• 80286 1982 16 1M 3
• 80386 1985 32 4G 11
• 80486 1989 32 4G 41
• Pentium1993 64 4G 111
53
Microcontroller
• Essentially a microprocessor with on-chip memories
and I/O devices
• Designed for specific functions
• All in one solution - Reduction in chip count
– Reduced cost, power, physical size, etc.
• Examples
– MC68332, MC68HC11, PPC555
• More details of components later
– A/D converters, temperature sensors, communications,
timing circuits, many others
54
Microcontroller Components – CPU
• Smart part
– Processes instructions
and data
– All the parts of a
microprocessor Register 0
address data
• Registers – fast memory Register 1
r/w Register n-1
used to store operands and
other information inst
ALU
– Condition register –
positive/negative result
– Exception register – CPU
overflow condition
– Loop count register
• Load-store architecture 55
•CPU
•On-chip peripherals and
memory
•Parallel and serial digital I/O
•Analog I/O
•Counters and timers
•Internal ROM and/or EPROM
Support Devices
Timers
A/D converter
Serial I/O
Common communication lines
System Bus
56
Microcontroller Components – Memory
• Each memory location has
a specific address
• We must supply an Memory location 0
Memory location 1
address to access the
corresponding location
address data
• R/W allows us to select
reading or writing Memory location n-2
• Various types of memory Memory location n-1
for different functions and
r/w
speeds
57
Microcontroller Components – Memory
• Read Only Memory - Memory that can only be read
– Holds the program code for a microprocessor
used in an embedded system where the code is
always the same and is executed every time the
system is switched on
– Computer BIOS, boot-up information
• Other types of Read Only Memory
– Erasable Programmable Read Only Memory
(EPROM) – Similar to ROM but can be erased
(exposure to ultraviolet light) and reprogrammed
– Electrically Erasable Programmable Read Only
Memory (EEPROM) – more common that EPROM
because it can be erased by the microprocessor
– Flash Memory, Ferroelectric RAM (FRAM),
Magnetic Random Access Memory (MRAM) 58
Microcontroller Components – Memory
• Random Access Memory – used to store dynamic data when processor
is running
– Holds program code and data during execution
– Can be accesses in any random order – unlike takes or disks
• Some types of RAM
– Static RAM (SRAM) – Uses transistors to store bits, fast SRAM is used
for cache
– Dynamic RAM (DRAM) – Uses capacitors to store bits, must be
refreshed, smaller and cheaper than SRAM
• Fast Page Mode (FPM), Extended Data Out (EDO)
• Synchrounous DRAM (SDRAM) – introduced in 1997 and replaced
most DRAM in computers by 2000
• Double Data Rate (DDR SDRAM) – uses both clock edges found
today in most computers
• Direct Rambus DRAM (RDRAM) – somewhat of a flop
59
Microcontroller Components – I/O
• Connection to the outside world
• Examples
– Analog to Digital Converter
– Temperature Sensor
– Display
– Communications Circuit
60
Microcontroller Components – BUS
• Group of wires used to transport information
• CPU to Memory
– Address bus
– Data bus
• CPU to I/O
– Port mapped I/O – used when address space is
limited, special instructions are needed for I/O
– Memory mapped I/O – I/O looks like memory
locations, easier to use and common in Reduced
Instruction Set Computing (RISC)
61
Microcontroller unit sales are 15x higher than
microprocessors. and cheaper but less feature and
processing power. Microcontrollers are a large market
with growth rate for 2003 is at 9.42%.
•16- and 32-bit and higher are on the rise. They will
double their unit market share from 15.11% in 1998 to
31.56% in 2003, decreasing 4-bit and 8-bit devices.
•The manufacturer Intel, AMD, PIC, ARMS, TI,
Motorola, Siemens, Hitachi, MIT, Renesas, Samsung.
•1994 Malaysia's first locally designed IC, 16-bit RISC
microprocessor, Pesona.
62
63
1.6 Embedded System
• Special purpose computer system usually completely inside the device it
controls
• Has specific requirements and performs pre-defined tasks
• primarily as a means to simplify the system design and to provide flexibility.
• Often the user of the device is not even aware that a computer is present.
• Cost reduction compared to general purpose processor
• Different design criteria
– Performance
– Cost
– Reliability
– Availability
– Safety
64
Types of Embedded System
65
Embedded controller is selected based on system
requirements;
66
What is a Real-Time System?
• Real-time systems process events.
• Events occurring on external inputs cause
other events to occur as outputs.
• Minimizing response time is usually a
primary objective, or otherwise the entire
system may fail to operate properly.
68
Embedded System Programming
Low Level Language
• Machine Language
A bundle of binary bits with certain formats
Only asks for simple operations
AA
09
9F
• Assembly
High speed, low code size
However, difficult to do a large project in assembly
Assembly: textual notations of machine program
69
High level language e.g. C
– Ease of management of large embedded projects
– Provides an additional level above assembly programming
– Fairly efficient
– Supports access to I/O
70
71
72
1.7 Embedded System Application
73
74
75
76
77
78
79
80
81
82
83
84
85
86
M-NOSE Ver 1.0
• Microcontroller - Hitachi 8-bit H8/3687
• RAM - 4KB 32MHz and 512 KB flash memory
• ADC - 8 channe10 bits
M-NOSE Ver 2.0
• Microcontroller - Rabbit 8-bit RCM4000
• RAM - 512KB 58MHz and 32MB flash memory
• ADC - 8 channe12 bits
M-NOSE Ver 3.0