You are on page 1of 39

EEE316

Microprocessors

LECTURE #1

Asst. Prof. Dr. Volkan


KILIÇ
Canvas page:
This course has enabled open enrolment. Students can self-enrol in the course once
you share with them this URL: https://canvas.instructure.com/enroll/DYWJ7J.
Alternatively, they can sign up at https://canvas.instructure.com/register and use the
following join code: DYWJ7J

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

– How long it takes to get data from memory


Semiconductor memories

• ROM (Read-only Memory)


- Mask ROM
- PROM (Programmable ROM)
- EPROM (Erasable PROM)
- EEPROM (Electronic Erasable PROM)
- Flash EPROM

• RAM (Random Access Memory)


- SRAM
- DRAM
- NV-RAM
Mask ROM
Memory\ROM\

• Programmed by the IC manufacturer


PROM (Programmable ROM)
Memory\ROM\

• OTP (One-Time Programmable)


– You can program it only once
EPROM (Erasable Programmable ROM)
Memory\ROM\

• 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

– No need for refreshing


• Disadvantages:
– High power consumption
– Expensive
DRAM (Dynamic RAM)
Memory\RAM\

• Made of capacitors
• Advantages:
– Less power consumption
– Cheaper
– High capacity
• Disadvantages:
– Slower
– Refresh needed
NV-RAM (Nonvolatile RAM)
Memory\RAM\

• Made of SRAM, Battery, control circuitry


• Advantages:
– Very fast
– Infinite program/erase cycle
– Non-volatile
• Disadvantage:
– Expensive
Internal parts of computers\CPU

• 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

CPU I/O 0 I/O 1 I/O 2 I/O n


Connecting I/Os and memory to CPU using bus
0
1

How could we manage it? 2


3

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

CPU3. Using a NAND, design a logic circuit whose output


activates when the fixed address is given to it.
a7 a6 a5 a4 a3 a2 a1 a0
From address 0  0 0 0 0 0 0 0 0 a4
I/O 16 I/O 17 I/O a5
18
a6
I/OCS
n
To address15  0 0 0 0 1 1 1 1 a7
Another example for address decoder
• Design an address decoder for address of 300H
to 3FFH.

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 BA
3 81h A  [6]
EAh
AA+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 BA
3 81h A  [6]
EAh
AA+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

D I/O 16 I/O 17 I/O 18 I/O n


Inst. Dec. registers

31
How computers work 0 31h
1 C4
C4h A [17]
2 26
26h BA
3 81h A  [6]
EAh
AA+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 BA
3 81
81h A  [6]
EA
EAh
AA+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

Operation Code Meaning


000 Ax
0011 0001 0 31h
1100 0100 1 C4h A [17] 001 A  [x]
0010 0110 BA
2 26h 010 A  A – register (x)
1000 0001 3 81h A  [6]
1110 1010 4 EAh
AA+B 011 AA+x
0000 0000
[7]A
5 0h 100 A  A + register (x)
0000 0101 6 5h
7
101 AA–x
110 Register (xH)  Register (xL)
111 [x]  A
Von Neumann vs. Harvard architecture

Data bus Data bus


Code Data
Memory Address bus CPU Address bus Memory
Control bus Control bus

• Von Neumann architecture

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

CPU RAM ROM

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

You might also like