16.317: Microprocessor System Design I

Slides:



Advertisements
Similar presentations
Instruction formats for the PIC series. ROM encoding Instructions are encoded in binary in ROM. The instructions are fixed format, each occupying 14 bits.
Advertisements

Control structures Hot to translate high level control structures to assembler.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 30: PIC data memory.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 29: Microcontroller intro.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2013 Lecture 27: PIC instruction set.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Instruction Set.
Microcontroller Programming How to make something almost do something else Raffi Krikorian MAS November 2003.
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Programmers Model and Instruction Set.
Two’s Complement Number wheel for 4 bit numbers
Building Assembler Programs Chapter Five Dr. Gheith Abandah1.
Microprocessor and Interfacing PIC Code Execution
PIC18F Programming Model and Instruction Set
Lecture – 4 PIC18 Family Instruction Set 1. Outline Literal instructions. Bit-oriented instructions. Byte-oriented instructions. Program control instructions.
Embedded System Spring, 2011 Lecture 11: Bank Switching Eng. Wazen M. Shbair.
EEE237 Introduction to Microprocessors Week x. SFRs.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
PIC Code Execution How does the CPU executes this simple program? void main() { int i; i = 1; i++; }
V 0.41 C Arithmetic operators OperatorDescription +, -addition (i+j), subtraction (i-j) *, /multiplication (i*j), division (i/j) ++, --increment (i++),
Embedded System Spring, 2011 Lecture 11: Bank Switching Eng. Wazen M. Shbair.
PIC12F629/675. “Wide variety” 8-84 pin RISC core, 12/14/16bit program word USART/AUSART, I 2 C, ADC, ICSP, ICD OTP/UV EPROM/FLASH/ROM Families: PIC12,
Department of Electronic & Electrical Engineering Lecture 4. ➢ Loops ➢ Delays ➢ Conditional instructions ➢ Simple clock example.
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
Microprocessor Systems Design I
Chapter 9 PIC18 Timer Programming in Assembly
Microprocessor Systems Design I
Microprocessor Systems Design I
Lecture – 5 Assembly Language Programming
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Micro-processor vs. Micro-controller
EECE.3170 Microprocessor Systems Design I
Microprocessor Systems Design I
C. K. PITHAWALA COLLEGE OF ENGINEERING AND TECHNOLOGY
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
PIC – ch. 2b Md. Atiqur Rahman Ahad.
PIC 16F877.
Microprocessor Systems Design I
16.317: Microprocessor System Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Md. Atiqur Rahman Ahad PIC18… Ch. 3.1 Md. Atiqur Rahman Ahad
EECE.3170 Microprocessor Systems Design I
Presentation transcript:

16.317: Microprocessor System Design I 9/11/2018 16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 33: PIC instruction set, pt. 3 Chapter 2

Microprocessors I: Lecture 33 Lecture outline Announcements/reminders Lab 4 due 4/25 Limited # of PICkits  strongly suggest you work in a group for the last two assignments PICkits can be checked out from the lab Lab 5 posted; report due 5/7 (last day of classes) HW 4 to be posted ASAP (hopefully later today) Likely our last homework assignment—doesn’t make sense to have both a homework assignment and lab due at the end of classes No lecture Friday Lecture outline Review: PIC instructions Logical ops Goto/call/return Misc Continue with PIC instructions 9/11/2018 Microprocessors I: Lecture 33

Review: PIC instructions Logical operations andlw/andwf iorlw/iorwf xorlw/xorwf Rotates rrf rlf Jumps/calls/return goto call return/retlw/retfie Miscellaneous nop sleep/clrwdt 9/11/2018 Microprocessors I: Lecture 33

Conditional Execution 9/11/2018 Conditional Execution STATUS bits: none Conditional execution in PIC: skip next instruction if condition true Two general forms Test bit and skip if bit clear/set Increment/decrement register and skip if result is 0 btfsc f, b ;Test bit b of register f, where b=0 to 7, skip if clear btfss f, b ;Test bit b of register f, where b=0 to 7, skip if set decfsz f, F(W) ;decrement f, putting result in F or W, skip if zero incfsz f, F(W) ;increment f, putting result in F or W, skip if zero Examples: btfsc TEMP1, 0 ; Skip the next instruction if bit 0 of TEMP1 equals 0 btfss STATUS, C ; Skip the next instruction if C==1 decfsz TEMP1, F ; Decrement TEMP1, skip if TEMP1==0 incfsz TEMP1, W ; W <- TEMP1+1 , skip if W==0 (TEMP1==0xFF) ; Leave TEMP1 unchanged 9/11/2018 Microprocessors I: Lecture 33 Chapter 9

Microprocessors I: Lecture 33 Example Show the values of all changed registers after each of the following sequences What high-level operation does each perform? (b) movf NUM2, W subwf NUM1, W btfss STATUS, C goto BL movf NUM1, W goto Done BL movf NUM2, W Done movwf MAX (a) movf a, W sublw 0xA btfsc STATUS, Z goto L1 incf b, W goto L2 L1 decf b, W L2 movwf a 9/11/2018 Microprocessors I: Lecture 33

Example solution (part a) movf a, W  W = a sublw 0xA  W = 10 – a btfsc STATUS, Z  Skip goto if result is non-zero goto L1  Goto L1 if result == 0  Reach this point if result non-zero incf b, W  W = b + 1 goto L2 L1 decf b, W  W = b - 1 L2 movwf a  a = W  value depends on what’s executed before this High-level operation: if ((10 – a) == 0) a = b – 1 else a = b + 1 9/11/2018 Microprocessors I: Lecture 33

Example solution (part b) movf NUM2, W  W = NUM2 subwf NUM1, W  W = NUM1 – W = NUM1 – NUM2 btfss STATUS, C  Carry indicates “above”  if set, NUM1 > NUM2 goto BL movf NUM1, W  if (NUM1 >= NUM2) W = NUM1 goto Done  Skip “below” section BL movf NUM2, W  if (NUM1 < NUM2) W = NUM2 Done movwf MAX High-level operation: if (NUM1 < NUM2) MAX = NUM2 else MAX = NUM1 9/11/2018 Microprocessors I: Lecture 33

PIC Microcontroller Prof. Yan Luo, UMass Lowell 9/11/2018 Working with 16-bit data Assume a 16-bit counter, the upper byte of the counter is called COUNTH and the lower byte is called COUNTL. Decrement a 16-bit counter movf COUNTL, F ; Set Z if lower byte == 0 btfsc STATUS, Z decf COUNTH, F ; if so, decrement COUNTH decf COUNTL, F ; in either case decrement COUNTL Test a 16-bit variable for zero btfsc STATUS, Z ; If not, then done testing movf COUNTH, F ; Set Z if upper byte == 0 btfsc STATUS, Z ; if not, then done goto BothZero ; branch if 16-bit variable == 0 CarryOn PIC Microcontroller Prof. Yan Luo, UMass Lowell Chapter 9

Microprocessors I: Lecture 33 9/11/2018 A Delay Subroutine ; *********************************************************************************** ; TenMs subroutine and its call inserts a delay of exactly ten milliseconds ; into the execution of code. ; It assumes a 4 MHz crystal clock. One instruction cycle = 4 * Tosc. ; TenMsH equ 13 ; Initial value of TenMs Subroutine's counter ; TenMsL equ 250 ; COUNTH and COUNTL are two variables TenMs nop ; one cycle movlw TenMsH ; Initialize COUNT movwf COUNTH movlw TenMsL movwf COUNTL Ten_1 decfsz COUNTL,F ; Inner loop goto Ten_1 decfsz COUNTH,F ; Outer loop goto Ten_1 return 9/11/2018 Microprocessors I: Lecture 33 Chapter 9

Microprocessors I: Lecture 33 Next time PIC programming examples Lab 5 discussion 9/11/2018 Microprocessors I: Lecture 33