Preliminary
Preliminary
Preliminary
and Microcontrollers
Ali Parsayan
ali.parsayan@freeuni.edu.ge
1
Preliminary
Cost Finding:
Activities: %10
Z80 Microprocessors
(Z80 CPU User Manual)
By: ZILOG
By: INTEL
4
References
Discovering
the STM32 Microcontroller
June 5, 2016
Revision: 14c8a1e (2016-06-05)
5
References
UM1472 Rev 7
October 2020
www.st.com
6
References
UM1472 Rev 7
October 2020
www.st.com
7
Prerequisites
• Mathematics I & II
• Programming and Computer Applications I & II
• Electrical Engineering I & II
• Analog Electronics
• Digital Electronics
8
Preface
9
Objectives
10
History of Microprocessors
• 1950s - The beginning of the digital era and electronic
computing
o Invention of transistor
• 1969 – Intel is a small startup company in Santa Clara
with 12 employees
o 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,
o ATARI is a startup company
o Creates a gaming console and releases PONG 11
History of Microprocessors
• 1974 – the first real useful 8-bit microprocessor is released by
Intel – the 8080
o Motorola introduces the 6800 series
o Zilog has the Z80
• 1975 – GM and Ford begin to put microcontrollers in cars
o Many cars today have over 100 microcontrollers
o TI gets into the microprocessor business with calculators and digital
watches
• 1977 – Apple II is released using MOS 6502 (similar to motorola
6800).
o Apple II dominated from 1977 to 1983
• 1978 – Intel introduces the first 16-bit processor, the 8086
o Motorola follows with the 68000 which is ultimately used in the first Apple
Macintosh
12
History of Microprocessors
13
History of Microprocessors
14
History
8008 8088/6
4004 80386 80860
intel 8080 80186
4040 80486 pentium
8085 80286
Z8000
zilog Z80 Z8001
Z8002
6800 68006 68020
Motorola 6802 68008 68030
6809 68010 68040
The 1st uP: Intel 4004
• Introduced 1971
• 2250 transistor
• 108 kHz, 60,000 ops/sec
• 16 pins
• 10-micron (0.001 millimeters) process
• As powerful as the ENIAC which had 18000 tubes and
occupied a large room
• Targeted use: Calculators
• Cost: less than $100
16
ENIAC General-Purpose Computer 1946
(Electronic Numerical Integrator and Computer)
17
Why Intel came up with the idea?
19
Intel Pentium 4 (2.2GHz)
22
Evolution of Intel Microprocessors
23
Evolution of Intel Microprocessors
24
4-, 8-, 16-, 32-, 64-bit (Word Length)
25
kHz, MHz, GHz (Clock Frequency)
27
Components of a Computer
• Input/Output
o Used to communicate with the outside world
28
Microprocessor
29
Microcontroller
30
Embedded System
• MPU (CPU)
o Read instructions
o Process binary data
32
Memory
• Storage Device
o Addresses
o Registers
• Major Categories
o Read/Write Memory (R/W)
o Read-only-Memory (ROM)
33
Input/Output (I/O)
• Input Devices
o Switches and Keypads
o Provide binary information to the MPU
• Output devices
o LEDs and LCDs
o Receive binary information from the MPU
34
Microprocessor-Based Systems
35
Microprocessor Architecture
37
Example Microprocessor System
38
Microcontrollers
• Embedded Systems
o Operations managed behind the scenes by a
microcontroller
• Microcontroller (MCU)
o An integrated electronic computing device that
includes three major components on a single chip
➢Microprocessor (MPU)
➢Memory
➢I/O (Input/Output) ports
39
Microcontrollers
• Support Devices
o Timers
o A/D converter
o Serial I/O
o ……….
• Common communication lines
o System Bus
40
Block Diagram
41
Microcontroller Components – Memory
46
ROM
A0 D0
A1 D1
m+1 bit A2 D2
Address n+1 bit
Data
Am 2m+1 (n + 1)
m +1 Dn
Capacity : 2 ROM
PROM
EEPROM
OEconnect
: : Output Enable
to RD of uP
D0-Dn
CE
OE
10 11
9 A0 O0 12
U1 U2 A1 O1
8 13
7 A2 O2 15
8 9 8 9 A3 O3
7 A0 O0 10 A0 O0 6 16
A1 O1 7 10 5 A4 O4 17
6 11 6 A1 O1 11 A5 O5
5 A2 O2 13 A2 O2 4 18
A3 O3 5 13 3 A6 O6 19
4 14 4 A3 O3 14 A7 O7
3 A4 O4 15 A4 O4 25
A5 O5 3 15 24 A8
2 16 2 A5 O5 16 A9
1 A6 O6 17 A6 O6 21
A7 O7 1 17 23 A10
23 23 A7 O7 A11
22 A8 A8 2
A9 22 A12
19 A9
A10 19 22
21 A10 OE
20 A11 27
OE 20 PGM
18 CE
CE 20
18 OE/VPP
21 1
VPP CE VPP
U6 12 13
U4 U5 11 A0 D0 14
10 11 10 A1 D1 15
10 11 10 11 9 A0 O0 12 9 A2 D2 17
9 A0 D0 12 9 A0 D0 12 A1 O1 A3 D3
A1 D1 A1 D1 8 13 8 18
8 13 8 13 7 A2 O2 15 7 A4 D4 19
7 A2 D2 15 7 A2 D2 15 A3 O3 A5 D5
A3 D3 A3 D3 6 16 6 20
6 16 6 16 5 A4 O4 17 5 A6 D6 21
5 A4 D4 17 5 A4 D4 17 A5 O5 A7 D7
A5 D5 A5 D5 4 18 27
4 18 4 18 3 A6 O6 19 26 A8
3 A6 D6 19 3 A6 D6 19 A7 O7 A9
A7 D7 A7 D7 25 23
25 25 24 A8 25 A10
24 A8 24 A8 A9 A11
A9 A9 21 4
21 21 23 A10 28 A12
23 A10 23 A10 A11 A13
A11 A11 2 29
2 2 26 A12 3 A14
26 A12 26 A12 A13 A15
A13 A13 27 2
27 1 A14 A16
22 A14 A15
OE 24
27 22 22 31 OE
20 PGM 20 OE OE/VPP PGM
CE CE 20 22
CE CE
1 1 28 1
VPP VPP VCC VPP
51
28XX E2PROM
12 13
11 A0 D0 14
10 A1 D1 15
12 13 A2 D2
11 A0 D0 14 9 17
A1 D1 8 A3 D3 18
10 11 10 15 A4 D4
A0 D0 9 A2 D2 17 7 19
9 12 A3 D3 A5 D5
10 11 8 A1 D1 13 8 18 6 20
A0 I/O0 A2 D2 A4 D4 5 A6 D6 21
9 12 7 15 7 19 A7 D7
8 9 A1 I/O1 A3 D3 6 A5 D5 20 27
A0 I/O0 8 13 6 16 A8
7 10 A2 I/O2 A4 D4 5 A6 D6 21 26
A1 I/O1 7 15 5 17 A9
6 11 A3 I/O3 A5 D5 27 A7 D7 23
A2 I/O2 6 16 4 18 A10
5 13 A4 I/O4 A6 D6 26 A8 25
A3 I/O3 5 17 3 19 A11
4 14 A5 I/O5 A7 D7 23 A9 4
A4 I/O4 4 18 25 A12
3 15 A6 I/O6 A8 25 A10 28
A5 I/O5 3 19 24 A13
2 16 A7 I/O7 A9 4 A11 29
A6 I/O6 25 21 A14
1 17 A8 A10 28 A12 3
A7 I/O7 24 1 23 A15
23 A9 RDY/BUSY A11 29 A13 2
A8 21 2 A16
22 23 A10 A12 3 A14 30
A9 26 A17
19 A11 A13 2 A15 1
A10 2 1 A18
A12 A14 A16
20 22 24 24
OE 22 OE
21 27 OE OE 31 OE 31
WE 27 WE
18 20 WE WE 22 WE 22
CE 20 CE
CE CE CE
24 28 32 32
VCC 28 VCC
VCC VCC VCC
52
EEPROM
53
RAM (Random Access Memory)
WR : Write signal
connect to MemWR of uP
CS : Chip Select
to Address decoder CS WR RD
55
Microcontroller Components – CPU
• Smart part
o Processes instructions and data
o All the parts of a microprocessor
• Registers – fast memory used to Register 0
address data
store operands and other Register 1
information r/w Register n-1
o Condition register – positive/negative
result inst
o Exception register – overflow ALU
condition
o Loop count register
• Load-store architecture CPU
56
Microcontroller Components – I/O
57
Microcontroller Components – BUS
• Machine instruction:
o A bundle of binary bits with certain formats
o Only asks for simple operations
o Assembly: textual notations of machine program
• Example:
C Compiler: c = a + b;
Assembly Compiler compiles to Machine execution:
r1 ← mem(a) //mov r1, [#M]
r2 ← mem(b) //mov r2, [#M]
r1 ← ADD r1, r2 //addc r1, r2
mem(c) ← r1 //mov [#M], r1
59
Machine-Level Execution
memory
I/O address
Load
CPU Stack
Store Data
Instruction
Fetch inst
60
Major Instruction Types
61
Processor Performance
• CPU Time
= # Cycles × Cycle Time
= # Instructions × CPI × Cycle Time
• CPI: Cycles per instruction
62
RISC
63
CISC
64
Embedded System Programming
68
Binary to Decimal Conversion
70
Software
• Machine Language
o Binary Instructions
o Difficult to decipher and write
➢ Error-prone
o All programs converted into machine language for
execution
Instruction Hex Mnemonic Description Processor
10000000 80 ADD B Add reg B to Acc Intel 8085
00101000 28 ADD A, R0 Add Reg R0 to Acc Intel 8051
00011011 1B ABA Add Acc A and B Motorola 6811
71
Software
• Assembly Language
o Machine instructions represented in
mnemonics
o One-to-one correspondence
o Efficient execution and use of memory
o Machine-specific
72
Software
• High-Level Languages
o BASIC, C, and C++
o Written in statements of spoken languages
o Machine independent
o Easy to write and troubleshoot
o Larger memory and less efficient execution
73
Data Format (8-bit)
• Unsigned Integers
oAll eight bits represent the magnitude
of a number
➢Bit7 to Bit0
oRange 00H to FFH (010 to 25510)
74
Data Format (8-bit)
• Signed Integers
o2's Complement
➢Bit 7 is sign bit
oPositive numbers:
➢00H to 7FH (010 to 12710)
oNegative numbers:
➢80H to FFH (-110 to -12810)
75
Data Format (8-bit)
76
Data Format (8-bit)
77
MPU-Based Systems
• System hardware
o Discrete components
➢Microprocessor, Memory, and I/O
o Components connected by buses
➢Address, Data, and Control
• System software
o A group of programs that monitors the
functions of the entire system
78
MPU-Based Time
and Temperature System
79
MCU-Based Systems
80
MCU-Based Time
and Temperature System
81
Programming Levels of Representation
Application (Netscape)
Operating
Compiler System
Assembler (Windows)
Software
Instruction Set
Hardware Processor Memory I/O system Architecture
82
Programming Levels of Representation
Compiler
Assembly Language
Program
Assembler
Machine Language
Program
Machine Interpretation
84
At the high end of the scale
Embedded Devices
86
Where are the embedded devices?
87
Computer Technology
→ Dramatic Change
• Processor
o 2X in speed every 1.5 years; 100X performance in last
decade
• Memory
o DRAM capacity: 2X/2 years; 64X size in last decade
o Cost per bit: improves about 25% per year
• Disk
o Capacity: > 2X in size every 1.0 years
o Cost per bit: improves about 100% per year
o 250X size in last decade 88
Computer Technology
→ Dramatic Change
• State-of-the-art PC when you graduate: (at least…)
o Processor clock speed:
➢ more than 5000 MegaHertz (5.0 GigaHertz)
o Memory capacity:
➢ more than 16000 MegaBytes (16.0 GigaBytes)
o Disk capacity:
➢ more than 5000 GigaBytes (5.0 TeraBytes)
o New units! Mega => Giga, Giga => Tera
o (Kilo, Mega, Giga, Tera, Peta, Exa, Zetta, Yotta = 1024)
89
Challenges for 21st Century
90
Why Study Microprocessor Design?
91
Why Study Microprocessor Design?
92
Why Study Microprocessor Design?
Wireless Sensor Networks Platform Power Metering Application
93
5 Classic Components of a Computer
Network/Bus
Processor Processor
Input Input
Control Control
Memory Memory
94
Microprocessor
Data
Cache
Memory
Bus Control Arithmetic
EM Bus Unit & Logic
Interface Unit
I/O Unit
Instruction Registers
System Decoder
Bus
Floating
Point
Unit
Instruction
Cache Registers
95
Von Neumann Model
96
Arithmetic & Logic Unit (ALU)
• Also known as the “Integer Unit”
• It performs whole-number math calculations
(subtract, multiply, divide, etc) comparisons (is
greater than, is smaller than, etc.) and logical
operations (NOT, OR, AND, etc)
• The new breed of popular uPs have more than
one identical ALU’s that can do calculations
simultaneously, increasing the capability
97
Floating-Point Unit (FPU)
100