Chapter 2
Chapter 2
Chapter 2
Harvard Architecture
Von Neumann Architecture
8-bit Bus
CPU
Harvard Architecture
Fetches instructions and data from a single memory space Limits operating bandwidth
Harvard Architecture:
8-bit Bus
Data Memory
16-bit Bus
CPU
Uses two separate memory spaces for program instructions and data Improved operating bandwidth Allows for different bus widths
Program Memory
PIC microcontrollers are designed using the Harvard Architecture which includes:
Microprocessor unit (MPU) Program memory for instructions Data memory for data I/O ports Support devices such as timers
Data Memory: 4 K
Data EEPROM
http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=1004&mi d=10&lang=en&pageId=74
2 MB 221
8 bit
4 KB 212
Design a micro controller with the following specifications Specify bus widths.
In your design show where the counter registers are located In your design show where the working registers are located (which part of the microprocessor unit) Show where the read/write lines are connected to specify the direction of each.
32 K (215)
PIC18F MCU and Memory Design Problem Design a micro controller with the following specifications Specify bus widths.
Data Memory: 4 K
32 K (215)
Microprocessor Unit (1 of 3)
WREG working register Status register that stores flags Instruction decoder when the instruction is fetched it goes into the ID
Microprocessor Unit (2 of 3)
Registers
16-bit registers used as memory pointers in indirect addressing data memory 21-bit register that holds the program memory address while executing programs
Microprocessor Unit (3 of 3)
Control unit
Provides timing and control signals to various Read and Write operations
Address bus
21-bit address bus for program memory addressing capacity: 2 MB of memory 12-bit address bus for data memory addressing capacity: 4 KB of memory
Data bus
16-bit instruction/data bus for program memory 8-bit data bus for data memory Read and Write
Control signals
Examples
Instructions
8-bit Program Memory
inst k
1 k 0 k 0 k 0 k 0 k 1 k 1 k 0 k
movlw k
0
0 0
0 1
Flash (4K) EEPROM can be accessed individually 36 I/O ports F FLASH C EPROM
PIC18F452/4520 Memory
Data memory with addresses Also called Data Register or File Register
FFF=212=16x256=4096=4K
Bank address (4-bit) + Instruction (8-bit) FSR contains the address of the data register Hence, MPU uses FSR
Bank 1 GPR
1FFh 200h
Bank 2 GPR
2FFh
Divided into 256-byte banks There are total of F banks Half of bank 0 and half of bank 15 form a virtual bank that is accessible no matter which bank is selected
D00h
Bank 13 GPR
DFFh E00h
256 Bytes
Bank 14 GPR
EFFh F00h F7Fh F80h FFFh
PORT A through PORT E Most I/O pins are multiplexed Generally have eight I/O pins with a few exceptions Addresses already assigned to these ports in the design stage Each port is identified by its assigned Special Function Registers (SFR) look at the previous slide
PORTA (address of F80) PORTB (address of F81) these are part of data memory or register file
If provides efficient communication between the two devices Examples: Sending a file to a printer, pressing a key on the key board
MPU Initiating
Unconditional
RST
HW
SW
Reset
Manual Reset Power-on Reset Brown-out Reset (power goes below a specifies value)
Timers
A value is loaded in the register and continue changing at every clock cycle time can be calculated Can count on rising or falling edge There are several timers: 8-bit, 16-bit Controlled by SFR
Serial interface supporting RS232 Another serial data communication
Addressable USART
A/D converter Parallel Slave Port (PSP) Capture, Compare and PWM (CCP Module)
ToCON
Sleep mode
Power-down mode Able to reset the processor if the program is caught in unknown state (e.g., infinite loop) EEPROM can be protected through SFR
Code protection
Table 2-1
How much of flash memory can be accessed? 13 bit 8K (1FFF) 9bit 512 Byte Effective address bus from data memory ? How many instruction sets can PIC16F687 be accessed?
35 It has no multiplication! compare Figure 2-8 and 2-9
Has 77 instructions
In PIC18F instruction set, all instructions are 16-bit word length except four instructions that are 32-bit length
0000 1110 XXXX XXXX (any 8-bit number) Copy Contents of W register in PORTC
Binary format:
Instruction
Opcode
k OR
Opcode
MOVLW
0 x25
Literal Value
Problem statement:
Hardware:
bidirectional (input or output) port; should be setup as output port for display
Illustration (2 of 5)
TRISC=0
Interfacing LEDs to PORTC Port C is F82H Note that PORT C is set to be an output! Hence, TRISC (address 94H) has to be set to 0
Illustration (3 of 5)
Program (software)
Logic 0 to TRISC sets up PORTC as an output port Byte 55H turns on alternate LEDs
;Load W register with 0 ;Set up PORTC as output ;Byte 55H to turn on LEDS ;Turn on LEDs ;Power down
PIC18 Simulator
Using the Program Memory editor type in the opcode MOVLW 00 and MOWWF TRISC,0 as described in page 52 of your textbook. Run the program in step-by-step mode and observe the PC. Observe how the NEXT INSTRUCTION changes. What is the value of final clock cycle? How long does it take to complete the program in sec.?
What is the address for TRISC? SFR F94 What is the address for PORTE? How many SFR registers we have? FFF-F80 How many GPR? 000-5FF How many bit PC has? Compare with Fig 2-8
Example
Leave space
Illustration (4 of 5)
Contains 55