Documente Academic
Documente Profesional
Documente Cultură
Munish Verma Astt. Prof., ECE Deptt. Haryana College of Technology & Management
Contents
Introduction to PIC Harvard Architecture & Pipelining Program Memory Considerations Register Pile Structure & Addressing Modes CPU Registers Instruction Set Simple operations
Introduction
Microcontrollers are small computer on a chip with some special properties: CPU, code memory, data memory and I/O ports all included on a single chip Dedicated to one task Small and low cost Embedded in many consumer devices PIC is Peripheral Interface Controller Why PIC is popular? (i) Speed (ii) Instruction set simplicity (iii) Integration of operational features (iv)Programmable timer options (v) Interrupt control (vi) Powerful output pin control (vii) I/O port expansion (viii)Serial programming via two pins (ix) EPROM/ OTP/ Rom options (x) PIC development tools
Mid-Range Core Devices (ex:12C50x, 16C5x) 14 bit wide code memory 8 level deep call stack 35 instructions PIC12 and PIC16 devices Increased opcode width allows addressing of more memory
PIC17 High End Core Devices (Ex:17C4x,17C7xx) never became popular and superseded by the PIC18 architecture 16 bit wide opcode, 16 level deep call stack 58 instructions Packages of 40 to 68 pins a memory mapped accumulator read access to code memory (table reads), direct register to register moves, an external program memory interface to expand the code space an 8bit x 8bit hardware multiplier auto-increment/decrement addressing
PIC24 and dsPIC 16 bit Microcontrollers Architectures differ significantly from prior models dsPICs are Microchip's newest family, digital signal processing capabilities Microchip's first inherent 16-bit (data) microcontrollers Hardware MAC (multiply-accumulate) Barrel shifting Bit reversal 16x16)-bit multiplication Other digital signal processing operations Can be efficiently programmed in C
Instructions are fetched from program memory using 14-bit-wide memory bus and are different from buses used for accessing variables in data memory, I/O ports etc.
Pipelining
Processor executes each instruction during the
In pipelining, the overlapping of the execute cycle of one instruction with the fetch cycle of the next instruction leads to the execution of a new instruction every cycle.
This lockup progression is broken whenever an instruction includes a branch operation.
member of PIC16C6x/7x family has either 2K or 4K addresses of program memory. A program memory of 2K addresses needs only an 11-bit program counter to access any address. A program memory of 4K addresses needs a 12-bit program counter. PIC family actually uses a 13-bit program counter ; allowing for extending the family to an 8K program memory without changing the CPU structure. For the 4K & 2K parts, the upper bit or bits are simply ignored during fetches from the program memory.
CPU Registers
7 0
Working register
7 0 6 0 5 4 3 2 1 0
STATUS (address H03 to H83) RP0 NOT_TO NOT_PD Z DC C Register bank select bit Reset status bit Reset status bit Zero bit Digit carry/ borrow bit Carry/borrow bit
FSR (address H04; H84) Indirect data memory add. pointer INDF (address H00; H80) accessing INDF accesses the location pointed to by FSR
Program Counter
PCL (address H02, H82)
12 0
Eight-level Stack
Instruction Set
Complete Instruction Set Suggestions for writing assembly language code: Write instruction mnemonics in lowercase (e.g., xorwf) Write special register names , RAM variable names, and bit names in uppercase (e.g., STATUS, RP0) Write instruction and subroutine labels in mixed case (e.g., Mainline, Loop Time) Examples: Single-bit manipulation
bcf bsf clrw clrf PORTB, 0 STATUS, C ;clear bit 0 of PORTB ;set the carry bit ;clear the working register, W ;clear temporary variable TEMP1
Clear/move
TEMP1
Instruction Set
Clear/move
movlw 5 moclw 10 ;load 5 into W ;Load D10 or H10 or B10 into W ;depending upon default representation TEMP1 ;Move W into Temp1 TEMP1, W ;move TEMP1 into W TEMP1, F ;Swap 4-bit nibbles of TEMP1
Increment/decrement/complement
incf TEMP1, F decf TEMP1, F comf TEMP1, F ;Increment TEMP1 ;Decrement TEMP1 ;Change 0s to 1s and 1s to 0s