Professional Documents
Culture Documents
EE366
Microprocessors and
Microcontrollers
Lecture 04
Basic Computer Architecture
• CPU (Central Processing Unit)
• Memory
• Input/Output
Buses
17
The PIC Families
18
The PIC Microcontroller
• The PIC stands for (Peripheral Interface Controller).
• Microchip introduced in 1989 its first microcontroller.
• It was a humble 8 pin device.
• Now microchip is a leading microcontroller manufacturer.
• There are different PIC microcontrollers:
– PIC with UV-EPROM
– PICxxFxx (Flash type)
– OTP (one-time-programmable)
• Example PIC16C432
– Masked version of PIC
19
Microchip 8-bit PIC Microcontrollers
20
Microchip 8-bit PIC Microcontrollers
21
The PIC in Class and Lab
• The PIC18F is the top of the line of 8-bit PIC
microcontrollers .
• In class we will concentrate on PIC18F.
• A good understanding of PIC18F will make it easy
to handle other 8-bit PIC microcontrollers.
• In the lab (lab 1 to 7) we will mainly use:
– The 20-Pin 8-Bit Microcontroller PIC16F690
– The 40 pin PIC16F917 which is an 8-Bit
Microcontrollers with LCD Driver
• In projects we will use the PIC18F
22
The PIC18 Architecture
• The PIC18 is an 8-bit family of microcontrollers
from Micro Chip that contain a
microprocessor, program memory, data
memory, and I/O ports.
• The PIC18 is a self-contained computer system
that rarely requires additional memory or I/O.
Example System
LCD Display
Optical Card
PIC18 Reader
Microcontroller
Keyboard
Serial Interface to
Host
Internal PIC18 Architecture
• Harvard Architecture: Separate program and
data memories.
• Program memory is 16-bits wide
• Data memory is 8-bits wide
• At least 16 I/O pins (two 8-bit named ports A
and B)
• Internal program stack (31 x 21)
26
I/O
Data Ports
Memory
8 wires
31 x 21
Stack Memory Timers
21 wires
8 wires Analog to
Digital
16 wires Converter
Program
Memory
Serial
Ports
Data
EEPROM
Other
8 wires
Peripherals
PIC Registers
• PIC have many registers.
• Registers are used for arithmetic and logic
operations.
• The Majority of PIC registers are 8-bits registers
• The PIC has one data type: 8-bit.
• Any data larger than 8 bits must be broken into 8-
bit chunks' before processing
D7 D6 D5 D4 D3 D2 D1 D0
MSB LSB
28
The WREG Register
• The working register called WREG or W is the most
important register or register file location in the
microcontroller.
• This register is used by most instructions in the
instruction set to hold the result from an operation
and also one of the numbers operated upon.
• Most computers contain a WREG often called an
accumulator.
• The WREG register is at address 0xFE8.
The WREG Register
MOVLW Instruction:
30
The WREG Register
ADDLW Instruction:
31
The WREG Register
REMARKS:
• ( WREG = A5H)
32
The PIC File Register
• The PIC has many other registers in addition to the
WREG register.
• They are called Data Memory Space to distinguish
them from Program Memory Space.
• Data Memory is called file register.
• The file register is read/write memory used by the
CPU for data storage, scratch pad, internal use and
functions
The PIC File Register
• File register size ranges from 32 bytes to several
thousands.
• Arithmetic & logic operation can be performed on
many location of the file register.
• The file register RAM is divided into two sections:
– SFR (Special Function Registers)
– GPR (General Purpose RAM)
SFRs (Special Function Register)
• Dedicated to specific functions (ALU status, timers,
serial communication, I/O ports, ADC, etc)
• The function of each SFR is fixed.
• The number of SFRs is different for each chip
depending on pin numbers and peripherals.
• The 8-pin PIC12F508 has 7 SFR
• The 40-pin PIC18F458 has 256 SFR
GPR (General-Purpose RAM)
• 8-bit RAM locations used for data storage and
scratch pad.
• The size of GPR is different for each chip.
• Larger GPR means more difficulty with Assembly.
• Larger GPR is better for C.
• The 8-pin PIC12F508 has 25 Bytes GBR ( 7 SFR + 25
GPR = 32 Byte File Register).
• Microchip provides data for RAM size as GPR size
(PIC12F508 has 25 Bytes RAM)
• The 40-pin PIC18F458 has 1536 Bytes GBR ( 256 SFR
+ 1536 GPR = 1792 Byte File Register).
GPR (General-Purpose RAM)
• We have GPR (RAM) + Flash (Program Memory) +
Data EEPROM (can also be added Externally)
38
File Registers for PIC18 Family
39
The Access Bank
• The access bank is divided equally (128 Byte
each) between SFR & GPR.
• Locations 00H to 7FH for GPR.
• GPR can be accessed directly by its address.
• Used to store I/O and serial ports data, timer
data, etc.
• Locations F80H to FFFH for SFR.
• SFR is at is at the last portion of file register.
40
File Registers for PIC18 Family
41
File Registers for PIC18 Family
42
SFR for PIC18 Family
43
DATA MEMORY MAP FOR PIC18F2580/4580 DEVICES
44
PIC Registers
0xFE0 Bank Select Register (BSR)