Professional Documents
Culture Documents
Microprocessors
LECTURE #1
Youtube page:
https://www.youtube.com/playlist?list=PL59T_fFSZbIyjdqX_9drKfeayaEcRJEuB
Textbook
PIC Microcontroller And Embedded Systems: using Assembly and C for PIC 18, M.
Mazidi, R. McKinlay and D. Causey, Prentice Fall, 2008.
Software:
Students are expected to download and install MPLAB X IDE, MPLAB XC8 Compiler
and mikroProg Suite for PIC (Check canvas syllabus for the links)
Grading Policy
Assignments: 20%
Midterm: 20%
Final Project: 25%
Final Exam: 35%
Final Project:
• Individual Project (no groups will be allowed)
• Check our YouTube page for inspiration
• You can bring your own Project or choose from sample projects (check
canvas)
• The source code of the previous year projects will be shared, so you must
improve the existing Project. Multiple students may choose the same
Project, however, competition between Project members will affect your
evaluation. We will check who makes the best contribution to the same
Project.
Topics
• Internal organization of computers
– The different parts of a computer
• I/O
• Memory
• CPU
– Connecting the different parts
• Connecting memory to CPU
• Connecting I/Os to CPU
– How computers work
Internal organization of computers
• CPU (execute/process information)
• Memory
• I/O
– Input
• E.g. Keyboard, Mouse, Sensor
– Output
• E.g. LCD, printer, hands of a robot
Memory
• Everything that can store, retain, and recall
information.
– E.g. hard disk, a piece of paper, etc.
Memory characteristics
• Capacity
– The number of bits that a memory can store.
• E.g. 128 Kbits, 256 Mbits
• Organization
4 bits
– How the locations are organized 0
128 locations
1
• E.g. a 128 x 4 memory has 128 locations, 2
4 bits each
…
• Access time
127
• UV-EPROM
– You can shine ultraviolet (UV) radiation
to erase it
– Erasing takes up to 20 minutes
– The entire contents of ROM are erased
2764
EEPROM (Electrically Erasable
Memory\ROM\
Programmable ROM)
• Erased Electrically
– Erased instantly
– Each byte can be erased separately
Flash ROM
Memory\ROM\
• Erased in a Flash
• the entire device is erased at once
Memory\RAM\ SRAM (Static RAM)
• Made of flip-flops (Transistors)
• Advantages: 2K x 8
– Faster SRAM
• Made of capacitors
• Advantages:
– Less power consumption
– Cheaper
– High capacity
• Disadvantages:
– Slower
– Refresh needed
NV-RAM (Nonvolatile RAM)
Memory\RAM\
• Tasks:
– It should execute instructions
• It should recall the instructions one after another
and execute them
Connecting memory to CPU
• Memory pin out
Connecting memory
Writing
Reading memory to CPU
to memory
from
Address
Address
CS
CS
OE
Data
Data
WE
WE
Time
Time
Connecting I/Os to CPU
• CPU should have
lots of pins! Mouse
Network
CPU Keyboard
Sound Card
Graphic Card
Connecting I/Os to CPU using bus
Address bus
Data bus
Write
Control bus Read
CPU
I/O 0 I/O 1 I/O 2 I/O n
Connecting I/Os and Memory to CPU
Address bus
Data bus
Write
Control bus Read
0
Address bus
Data bus
Write
Control bus Read
CPU
I/O 0 I/O 1 I/O 2 I/O n
Connecting I/Os and Memory to CPU using bus
(Peripheral I/O)
0
1
..
63
Address bus
Data bus
Write
Control bus Read
IO/MEM
CPU
I/O 0 I/O 1 I/O 2 I/O n
Connecting I/Os and Memory to CPU using bus
(Memory Mapped I/O)
0 The logic circuit
1 enables CS
How could we make the logic ..
15
when address is
circuit? between 0 and
15
Logic circuit
Address bus
Data bus
Solution
Control 1.
bus Write
Write the address range in binary
Read
2. Separate the fixed part of address
Solution
1. Write the address range in binary
2. Separate the fixed part of address
3. Design the logic circuit.
a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 a8
a9
From address 300H 0 0 1 1 0 0 0 0 0 0 0 0 a10 CS
a11
To address 3FFH 001111111111
An easy way of
designing
Inside the CPU
• PC (Program Counter)
• Instruction decoder
• ALU (Arithmetic Logic Unit)
• Registers
PC A
ALU B
CPU C
D
Instruction decoder
registers
How computers work 0 31h
31
1 C4h A [17]
2 26h BA
3 81h A [6]
EAh
AA+B
4
[7]A
5 0h
6 5h
7
Logic circuit
Address bus
Data bus
Write
Control bus Read
ALU
CPU A
B
PC: 10 C
D I/O 16 I/O 17 I/O 18 I/O n
Inst. Dec. registers
How computers work 0 31h
1 C4h A [17]
2 26h BA
3 81h A [6]
EAh
AA+B
4
[7]A
5 0h
6 5h
7
Logic circuit
Address bus 17
Data bus
Write
Control bus Read
ALU
CPU A
B
PC: 1 C 9
31
How computers work 0 31h
1 C4
C4h A [17]
2 26
26h BA
3 81h A [6]
EAh
AA+B
4
[7]A
5 0h
6 5
5h
7
Logic circuit
Address bus 17
6
Data bus
Write
Control bus Read
ALU
CPU 9
A
B
PC: 1
2
3 C
D I/O 16 I/O 17 I/O 18 I/O n
Inst. Dec. registers
How computers work 0 31h
1 C4h A [17]
2 26h BA
3 81
81h A [6]
EA
EAh
AA+B
4
[7]A
5 0h
6 5h
7
7 Logic circuit
Address bus
Eh
Data bus
Write
Control bus Read
+
ALU
E CPU A
9
B
E
5
PC: 4
35 C
D I/O 16 I/O 17 I/O 18 I/O n
Inst. Dec. registers
How Instruction decoder works
Opcode Operand Opcode Operand
Instruction
Instruction
Code Data
Memory Memory
Data bus
CPU Address bus
Control bus
• Harvard architecture
Microprocessor vs. Microcontroller
• Microprocessor is general-purpose microprocessors
such as Intel’s x86 family.
• Microprocessor does not contain RAM, ROM or
I/O Ports on the chip it self.
• Microcontroller has CPU and fixed amount of RAM,
ROM, I/O Ports and Timer all on a single chip.
General Purpose Microprocessors vs.
Microcontrollers
• General Purpose Microprocessors
Data BUS
General Serial
IO
Purpose RAM ROM Timer COM
Port
Micro Port
processor Address BUS
Control BUS
• Microcontrollers
Serial
Timer I/O
Port
Choosing a µController
• The major 8-bit
– Freescale Semiconductor’s (formerly Motorola)
68HC08/68HC11
– Intel’s 8051
– Atmel’s AVR
– Zilog’s Z8
– PIC from Microchip Technology
Criteria for Choosing µController
1. Meeting the computing needs of the task at hand
efficiency and cost effectively
2. Availability of SW and HW development tools
– Compilers
– Assemblers
– Debuggers
– Emulators
3. Wide availability and reliable source.
Criteria for Choosing µController
• Meeting the computing needs of the task at hand
efficiency and cost effectively
– Determine its type, 8-bit,16-bit or 32-bit
– Speed
– Packaging (40-Pin or QFP)
– Power consumption
– The amount of RAM and ROM
– The number of I/O pins and the timer
– Cost per unit
– Ease of upgrade.
µController Data width
• 8-bit Microcontrollers
– PIC10, PIC12, PIC14
– PIC16, PIC17, PIC18
• 16-bit Microcontrollers
– PIC24F, PIC24H
• 32-bit Microcontrollers
– PIC32
• 16-bit Digital Signal Controllers
– dsPIC30, dsPIC33F