0% found this document useful (0 votes)
16 views27 pages

Bai2 Memory

Uploaded by

Dương Thịnh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views27 pages

Bai2 Memory

Uploaded by

Dương Thịnh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

PIC16F887

Lesson 2

MEMORY
ORGANIZATION
PIC16F887
PIC16F887

Harvard Architecture
Von Neumann
Architecture
Von Neumann Architecture:
Fetches instructions and data
from a single memory space
8-bit
Limits operating bandwidth
Program
Bus & Data
Memory
CPU

Harvard
Harvard Architecture:
Architecture
Uses two separate memory
spaces for program
8-bit
Bus
Data instructions and data
Memory
14-bit
CPU Improved operating bandwidth
Program
Bus
Allows for different bus widths
Memory
PIC16F887

Long Word Instruction


8-bit Instruction on typical 8-bit MCU
Example: Freescale ‘Load Accumulator A’:
• 2 Program Memory Locations
• 2 Instruction Cycles to Execute
ldaa #k => Limits Bandwidth
1
1 0
0 0
0 0
0 0
0 1
1 1
1 0
0 => Increases Memory Size Requirements
k
k k
k k
k k
k k
k k
k k
k k
k

14-bit Instruction on PIC16 8-bit MCU


Example: ‘Move Literal to Working Register’
• 1 Program Memory Location
• 1 Instruction Cycle to Execute
=>Separate busses allow
different widths
movlw k
=>2k x 14 is roughly equivalent
1
1 1
1 0
0 0
0 0 0 k k k k k k k
0 0 k k k k k k k kk
to 4k x 8
PIC16F887
PIC16F887

PIC16F887 MEMORY
The PIC16F887 has three types of
memory:

 ROM
 RAM
 EEPROM
PIC16F887

ROM MEMORY
 ROM memory is used to permanently
save the program being executed.
 This is why it is often called ‘program
memory’.
 The PIC16F887 has 8Kb of ROM (in total
of 8192 locations).
 Since the ROM memory is made with
FLASH technology, its contents can be
changed by providing a special
programming voltage (13V)
PIC16F887

ROM MEMORY
PIC16F887

EEPROM MEMORY
 Similar to program memory, the
contents of EEPROM is permanently
saved, even when the power goes off.
 However, unlike ROM, the contents of
EEPROM can be changed during the
operation of the microcontroller.
 This is why this memory (256 locations)
is perfect for permanently saving some
of the results created and used during
the operation.
PIC16F887

RAM MEMORY

RAM memory consists of two parts:


 General-purpose registers
 Special-function registers (SFR).
All these registers are divided in four
memory banks
RAM memory will lose it’s content
when the power goes off
PIC16F887

RAM MEMORY
PIC16F887

GENERAL-PURPOSE REGISTERS

General-purpose registers are used


for storing temporary data and
results created during operation.
PIC16F887

SPECIAL FUNCTION REGISTERS (SFRS)


 Special-function registers are also RAM
memory locations, but unlike general-
purpose registers, their purpose is
predetermined during manufacturing process
and cannot be changed.
 Since their bits are connected to particular
circuits on the chip (A/D converter, serial
communication module, etc.), any change of
their contents directly affects the operation of
the microcontroller or some of its circuits.
PIC16F887

RAM MEMORY BANKS


PIC16F887

RAM MEMORY BANKS


PIC16F887

RAM MEMORY BANKS


PIC16F887

RAM MEMORY BANKS


PIC16F887

RAM MEMORY BANKS


PIC16F887

STACK
 A part of RAM used as stack consists of eight
13-bit registers.
 Before the microcontroller starts to execute a
subroutine (CALL instruction) or when an
interrupt occurs, the address of the first next
instruction to execute is pushed onto the
stack, i.e. one of its registers.
 It helps microcontroller know from where to
continue regular program execution upon a
subroutine or an interrupt execution.
PIC16F887

STATUS REGISTER

The STATUS register contains: the status of


data in the W register, the RESET status and
the bank select bits for data memory.

IRP - Bit selects register bank. It is used for


indirect addressing.
 1 - Banks 0 and 1 are active
 0 - Banks 2 and 3 are
PIC16F887

STATUS REGISTER

RP1,RP0 - Bits select register bank. They


are used for direct addressing.
ACTIVE
RP1 RP0
BANK
0 0 Bank0
0 1 Bank1
1 0 Bank2
1 1 Bank3
PIC16F887

STATUS REGISTER

TO - Time-out bit.
 1 - After power-on, after executing the
CLRWDT instruction which resets the
watch-dog timer or the SLEEP
instruction which sets the microcontroller
into low-consumption mode.
 0 - After watch-dog timer time-out has
occurred.
PIC16F887

STATUS REGISTER

PD - Power-down bit.
 1 - After power-on or after executing the
CLRWDT instruction which resets the
watchdog timer.
 0 - After executing the SLEEP
instruction which sets the
microcontroller into low-consumption
mode.
PIC16F887

STATUS REGISTER

Z - Zero bit
 1 - The result of an arithmetic or
logic operation is zero.
 0 - The result of an arithmetic or
logic operation is different from
zero.
PIC16F887

STATUS REGISTER

DC - Digit carry/borrow bit is changed


during addition and subtraction if an
‘overflow’ or a ‘borrow’ of the result
occurs.
 1 - A carry-out from the 4th low-
order bit of the result has occurred.
 0 - No carry-out from the 4th low-
order bit of the result has occurred.
PIC16F887

STATUS REGISTER

C - Carry/Borrow bit is changed during


addition and subtraction if an ‘overflow’ or
a ‘borrow’ of the result occurs, i.e. if the
result is greater than 255 or less than 0.
 1 - A carry-out from the most significant
bit (MSB) of the result has occurred.
 0 - No carry-out from the most
significant bit (MSB) of the result has
occurred.
PIC16F887

Lesson 2

MEMORY
ORGANIZATION

You might also like