Microprocessors and Microcontrollers. Loops and Timing EE3954. by Maarten Uijt de Haag, Tim Bambeck. Loops & Timing.1

Size: px
Start display at page:

Download "Microprocessors and Microcontrollers. Loops and Timing EE3954. by Maarten Uijt de Haag, Tim Bambeck. Loops & Timing.1"

Transcription

1 Microprocessors and Microcontrollers Loops and Timing EE3954 by Maarten Uijt de Haag, Tim Bambeck Loops & Timing.1

2 Branching if then Decision Process A Process B instructions to set up condition btfss goto ProcessA goto ProcessB Example: execute code at LOC_1 if a 0 occurs at PORTB,0 execute code at LOC_2 if a 1 occurs at PORTB,0 btfss PORTB,0 goto LOC_1 goto LOC_2 OR btfsc PORTB,0 goto LOC_2 goto LOC_1 Loops & Timing.2

3 Loops for loop and while/repeat loop N Continue Main Program Set Counter Process A Decrement Counter Counter 0? Y Set up Condition Condition True Y Process A N Continue Main Program N Continue Main Program Process A Set up Condition Condition False Y Perform Process A Counter times Perform Process A while condition is true Loops & Timing.3

4 Loops for loop Use DECFSZ COUNT equ 0x20 ; Set up the counter value movlw d 3 ; SET COUNTER To Three movwf COUNT ; Store it in a GP register. NXT: ; PROCESS A decfsz COUNT,F ; Decrement and check if zero goto NXT ; Continue the main program Loops & Timing.4

5 Loops while/repeat until loop Example: Execute ProcessA subroutine until w contains the value decimal 99 Recall: Sublw = literal (W) -> W NXT: sublw d 99 btfsc STATUS,Z goto DONE call ProcessA goto NXT DONE Does not necessarily execute Process A NXT: call ProcessA sublw d 99 btfss STATUS,Z goto NXT DONE Always executes Process A at least once Loops & Timing.5

6 Loops Repeat Until Example CLR2070: movlw 0x20 ; set first address of the list movwf FSR ; by setting FSR NXT1: clrf INDF ; element of the list incf FSR,F ; increment the list pointer movlw 0x70 ; check if the end of the list subwf FSR,W ; reached here: 0x70 btfss STATUS,Z ; skip next inst. If f-(w) = 0 goto NXT1 ; goto next element in the list return Question = will location 0x70 get cleared? Loops & Timing.6

7 Timing Analysis Remember: 1 Instruction Cycle takes 4 Oscillator Cycles T = 4T cy osc Most instructions take 1 instruction cycle to execute Some instructions take 2 instruction cycles to execute: GOTO, CALL, RETURN, RETLW, RETFIE Some instructions take either 1 or 2 instruction cycles to execute: DECFSZ, INCFSZ, BTFSC, BTFSS Loops & Timing.7

8 Timing Analysis DECFSZ, INCFSZ, BTFSC, BTFSS if a SKIP does NOT occur: if a SKIP occurs: 1 instruction cycle 2 instruction cycles Execute 1 Fetch 2 Execute 2 Fetch 3 Execute 3 Fetch 4 Execute 1 Fetch 2 Execute 2 Fetch 3 Fetch 4 Execute 4 Fetch 5 Oops, the microcontroller just fetched the wrong instruction Loops & Timing.8

9 Timing Analysis org 0x000 NXT: movlw 0x28 ; 1 instruction cycle movwf PORTB ; 1 instruction cycle nop ; 1 instruction cycle movf PORTC,W ; 1 instruction cycle sublw 0xAA ; 1 instruction cycle btfss STATUS,Z ; 2 if taken; 1 is not taken goto NXT ; 2 instruction cycles A Disregarding first fetch instruction cycle time: If the skip is taken the first time the time it takes to get to point A is: delay = = 7 instruction cycles If the skip is taken the second time the time it takes to get to point A is: delay = ( ) + ( ) = 15 instruction cycles Loops & Timing.9

10 Timing Analysis With an external oscillator of 4MHz: 1 T osc = = = µ Oscillator period T = 4T = 1.0 µ sec cy osc seconds 0.25 sec instruction cycle 7 instruction cycles = 7 * 1.0 µsec = 7 µsec 15 instruction cycles = 15 * 1.0 µsec = 15 µsec Loops & Timing.10

11 Timing Analysis Subroutines call SUB_1 ; 2 SUB_1: andlw 0x0F ; 1 movwf TEMP ; 1 movlw 0x12 ; 1 subwf TEMP,F ; 1 return ; 2 A) Subroutine itself takes: 6 instruction cycles B) Calling the subroutine costs: 2 instruction cycles C) Totally, it costs: 6+2 = 8 instruction cycles to call and execute the subroutine Loops & Timing.11

12 Timing Loops Building Delays 1: A: movlw d 3 ; 1 instruction cycle 2: movwf COUNT ; 1 instruction cycle 3: NXT: nop ; 1 instruction cycle 4: decfsz COUNT,F ; 1or2 instruction cycles 5: goto NXT ; 2 instruction cycles B: Line: Instruction duration: Times Executed: Execution time: COUNT 1*COUNT 4 1 COUNT-1 1*COUNT COUNT-1 2*(COUNT-1) Loops & Timing.12

13 Timing Loops Building Delays 1: A: movlw d 3 ; 1 instruction cycle 2: movwf COUNT ; 1 instruction cycle 3: NXT: nop ; 1 instruction cycle 4: decfsz COUNT,F ; 1or2 instruction cycles 5: goto NXT ; 2 instruction cycles B: Time to go from A to B is: (1 + 1) + COUNT + COUNT (COUNT 1) = (2) = 13 instruction cycles So with an oscillator of 4MHz: delay takes 13 * 1 µsec = 13 µsec Loops & Timing.13

14 Timing Loops What is the general expression for this delay given any value for COUNT? # Instructions = 1+ 4*COUNT So, what is the maximum delay we can do with this construction? COUNT is a byte so its maximum value is 255!! Maximum value for delay is therefore: 1+4*255 = 1021 cycles, or 1021*1.0 µsec = 1021 µsec (0 gives 1+4*256) = 1025 cycles because decfsz 0->255). Loops & Timing.14

15 Timing Loops Even shorter COUNT equ 0x20 org 0x100 A: movlw d 10 ; 1 movwf COUNT ; 1 NXT: decfsz COUNT,F ; 1 (2) goto NXT ; 2 instruction cycles B: Time to go from A to B is: (1 + 1) *(10-1) = 31 instruction cycles # Instructions = 1+ 3*COUNT Loops & Timing.15

16 Timing Loops Even shorter Set Counter Decrement Counter N Counter 0? Continue Main Program Y Loops & Timing.16

17 Set Outer Counter Set Inner Counter Timing Loops Nested Loops Flowchart Decrement Inner Counter Inner Loop N Inner Counter 0? Y Decrement Outer Counter Outer Loop N Outer Counter 0? Continue Main Program Y Loops & Timing.17

18 Timing Loops Nested Loops - Assembly F equ d 1 ; destination-> file reg. COUT equ 0x20 ; outer counter storage CIN equ 0x21 ; inner counter storage org 0x0100 ; program location - start OUTER: movlw d 10 ; 1 movwf COUT ; 1 INNER: movlw d 255 ; 1 movwf CIN ; 1 NXT: decfsz CIN,F ; 1 (2) goto NXT ; 2 decfsz COUT,F ; 1 (2) goto INNER ; 2 B: Loops & Timing.18

19 Timing Loops Nested Loops - Computations Inner loop: Outer loop: Δ Outer Δ = 1+ 3 CIN Inner = 1+ 3 COUT = 1+ = 1+ ( 3 + Δ Inner ) ( CIN ) = 1+ 4 COUT + Δ Inner COUT COUT COUT + 3 CIN COUT For example, on the previous slide COUT = 10 and CIN = 255: ΔInner = = ΔOuter = 1+ (3+ 766) 10 = 766 7,691 (@ 4MHz -> msec delay) Loops & Timing.19

20 Timing Loops Fine-Tuning By inserting instructions (most of the time nop instructions) the inner loop delay can be changed and as a result the outer loop. Similarly, instructions can be added to the outer loop. Loops & Timing.20

21 Timing Loops Fine Tuning with nop s : COUT equ 0x20 CIN equ 0x21 org 0x00 OUTER: movlw 0x0A ; 1 movwf COUT ; 1 INNER: movlw 0xFF ; 1 movwf CIN ; 1 nop ; 1 NXT: decfsz CIN,F ; 1 (2) goto NXT ; 2 decfsz COUT,F ; 1 (2) goto INNER ; 2 B: Δ = 1+ 3 ( + Δ ) COUT Outer Inner ΔInner = CIN Increment this if nop is inserted inside the loop 2 instead of 1 Since nop is inserted outside the loop Loops & Timing.21

22 Timing Loops Design Subroutines call DELAY ;2 DELAY : movlw d 10 ; 1 movwf COUT ; 1 INNER: movlw d 255 ; 1 movwf CIN ; 1 NXT: decfsz CIN,F ; 1 (2) goto NXT ; 2 decfsz COUT,F ; 1 (2) goto INNER ; 2 return ; 2 Add 2 instruction cycles to the delay for the call statement, and 2 instruction cycles for the return statement Loops & Timing.22

Section 29. Instruction Set

Section 29. Instruction Set M Section 29. Instruction Set HIGHLIGHTS This section of the manual contains the following major topics: 29. Introduction...29-2 29.2 Instruction Formats...29-4 29.3 Special Function Registers as Source/Destination...29-6

More information

PIC Programming in Assembly. (http://www.mstracey.btinternet.co.uk/index.htm)

PIC Programming in Assembly. (http://www.mstracey.btinternet.co.uk/index.htm) PIC Programming in Assembly (http://www.mstracey.btinternet.co.uk/index.htm) Tutorial 1 Good Programming Techniques. Before we get to the nitty gritty of programming the PIC, I think now is a good time

More information

10-bit Σ ADC from a PIC16F84

10-bit Σ ADC from a PIC16F84 1-bit Σ ADC from a PIC16F84 Jesús Arias 22nd November 23 1 The circuit +5V 1 + 1uF 1nF 1nF 33 4.7 V DTR U1 Analog Input ( 5 Volt) R3 68K R1 1K R2 1K C1 33nF PIC16F84 RB7 RA2 RA3 ad2.asm OSC1 OSC2 X1 R4

More information

AN727. Credit Card Reader Using a PIC12C509 DATA ENCODING INTRODUCTION FIGURE 1: POSITION OF ISO TRACKS 1, 2 AND 3. Andrew M Errington

AN727. Credit Card Reader Using a PIC12C509 DATA ENCODING INTRODUCTION FIGURE 1: POSITION OF ISO TRACKS 1, 2 AND 3. Andrew M Errington Credit Using a PIC12C509 AN727 Author: INTRODUCTION Andrew M Errington Many people carry one or more magnetically encoded cards with them for accessing a range of services. Perhaps the most common example

More information

SPI. Overview and Use of the PICmicro Serial Peripheral Interface. Getting Started: SPI

SPI. Overview and Use of the PICmicro Serial Peripheral Interface. Getting Started: SPI SPI Overview and Use of the PICmicro Serial Peripheral Interface In this presentation, we will look at what the Serial Peripheral Interface, otherwise known as the SPI, is, and how it is used to communicate

More information

Flow Charts & Assembly Language

Flow Charts & Assembly Language Microprocessors and Microcontrollers Flow Charts & Assembly Language EE3954 by Maarten Uijt de Haag, Tim Bambeck, Harsha Chenji Flowcharts.1 Flow Chart Diagram of the sequence of operations in a computer

More information

How To Program A Microcontroller With Memory On A Microchip Microcontroller

How To Program A Microcontroller With Memory On A Microchip Microcontroller Getting Started with On-chip Memory 2001 Microchip Technology Incorporated. All Rights Reserved. S0001A RAM/ROM(x14) 1 In this Getting Started tutorial you will learn about the various memory types found

More information

Four-Channel Digital Voltmeter with Display and Keyboard. 8 x 220W RB0 RB1 RB2 RB3 RB4 RB5 RB6 RB7 RA0 RA1 RA2 RA3 PIC16C71

Four-Channel Digital Voltmeter with Display and Keyboard. 8 x 220W RB0 RB1 RB2 RB3 RB4 RB5 RB6 RB7 RA0 RA1 RA2 RA3 PIC16C71 Four-Channel Digital Voltmeter with Display and Keyboard Author: Stan D Souza Microchip Technology Inc. MULTIPLEXING FOUR 7-SEGMENT LED DISPLAYS INTRODUCTION The PIC16C71 is a member of the mid-range family

More information

Embedded C Programming

Embedded C Programming Microprocessors and Microcontrollers Embedded C Programming EE3954 by Maarten Uijt de Haag, Tim Bambeck EmbeddedC.1 References MPLAB XC8 C Compiler User s Guide EmbeddedC.2 Assembly versus C C Code High-level

More information

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan PIC18 Timer Programming g Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan chanhl@mail.cgu.edu.twcgu Functions of PIC18 timer Functions of the timer Generate a time delay As

More information

Analog-to-Digital Converters

Analog-to-Digital Converters Analog-to-Digital Converters In this presentation we will look at the Analog-to-Digital Converter Peripherals with Microchip s midrange PICmicro Microcontrollers series. 1 Analog-to-Digital Converters

More information

Simple Alarm System WIRELESS AND REMOTE CONTROLLED PERSONAL APPLIANCE CODE WORD ORGANIZATION TRANSMISSION FORMAT

Simple Alarm System WIRELESS AND REMOTE CONTROLLED PERSONAL APPLIANCE CODE WORD ORGANIZATION TRANSMISSION FORMAT Simple Alarm System WIRELESS AND REMOTE CONTROLLED PERSONAL APPLIANCE Author: Kirill Yelizarov V. Moscow Power Engineering Institute Moscow, Russia email: tihonov@srv-vmss.mpei.ac.ru The alarm system discussed

More information

Chapter 2: Assembly Language Programming. The PIC18 Microcontroller. Han-Way Huang

Chapter 2: Assembly Language Programming. The PIC18 Microcontroller. Han-Way Huang Chapter 2: Assembly Language Programming The PIC18 Microcontroller Han-Way Huang Minnesota State University, Mankato H. Huang Transparency No.2-1 Components of an Assembly Program - Assembler directives

More information

AN857. Brushless DC Motor Control Made Easy INTRODUCTION S 001 B. Anatomy of a BLDC SIMPLIFIED BLDC MOTOR DIAGRAMS

AN857. Brushless DC Motor Control Made Easy INTRODUCTION S 001 B. Anatomy of a BLDC SIMPLIFIED BLDC MOTOR DIAGRAMS Brushless DC Motor Control Made Easy AN857 Author: INTRODUCTION Ward Brown Microchip Technology Inc. This application note discusses the steps of developing several controllers for brushless motors. We

More information

AN730. CRC Generating and Checking INTRODUCTION THEORY OF OPERATION EXAMPLE 1: MODULO-2 CALCULATION. Example Calculation. Microchip Technology Inc.

AN730. CRC Generating and Checking INTRODUCTION THEORY OF OPERATION EXAMPLE 1: MODULO-2 CALCULATION. Example Calculation. Microchip Technology Inc. CRC Generating and Checking AN730 Authors: Thomas Schmidt INTRODUCTION This application note describes the Cyclic Redundancy Check (CRC) theory and implementation. The CRC check is used to detect errors

More information

Using The PIC I/O Ports

Using The PIC I/O Ports EE2801 -- Lecture 22 Using The PIC I/O Ports EE2801-L22P01 The Variety Of Available IO Ports The PIC 16F874 microcontroller has five different IO ports, accounting for thirty three of the processors forty

More information

Digital DC Motor Speed Regulator

Digital DC Motor Speed Regulator Digital DC Motor Speed Regulator This project is for a microcontroller-based DC motor speed regulator, being used to control a small Chinese-made rotary tool. The tool is available at Harbor Freight as

More information

AN585. A Real-Time Operating System for PICmicro Microcontrollers INTRODUCTION. Why do I Need a Real-Time Kernel? What is Multitasking Anyway?

AN585. A Real-Time Operating System for PICmicro Microcontrollers INTRODUCTION. Why do I Need a Real-Time Kernel? What is Multitasking Anyway? A Real-Time Operating System for PICmicro Microcontrollers Author: INTRODUCTION Jerry Farmer Myriad Development Company Ever dream of having a Real-Time Kernel for the PIC16CXXX family of microcontrollers?

More information

SSPBUF. Shift Clock SSPSR. START bit, STOP bit, Acknowledge Generate

SSPBUF. Shift Clock SSPSR. START bit, STOP bit, Acknowledge Generate Using the PICmicro MSSP Module for Master I 2 C TM Communications AN735 Author: INTRODUCTION Richard L. Fischer Microchip Technology Inc. This application note describes the implementation of the PICmicro

More information

EMBEDDED SYSTEMS PROGRAMMING WITH THE PIC16F877

EMBEDDED SYSTEMS PROGRAMMING WITH THE PIC16F877 EMBEDDED SYSTEMS PROGRAMMING WITH THE PIC16F877 Second Edition By Timothy D. Green Copyright 2008 by Timothy D. Green All Rights Reserved. Table of Contents Preface. 5 List of Figures. 6 Abbreviations

More information

PIC in Practice. A Project-Based Approach. D. W. Smith

PIC in Practice. A Project-Based Approach. D. W. Smith PIC in Practice PIC in Practice A Project-Based Approach D. W. Smith AMSTERDAM BOSTON HEIDELBERG LONDON NEW YORK OXFORD PARIS SAN DIEGO SAN FRANCISCO SINGAPORE SYDNEY TOKYO Newnes is an imprint of Elsevier

More information

AN857. Brushless DC Motor Control Made Easy INTRODUCTION S 001 B. Anatomy of a BLDC SIMPLIFIED BLDC MOTOR DIAGRAMS. Microchip Technology Inc.

AN857. Brushless DC Motor Control Made Easy INTRODUCTION S 001 B. Anatomy of a BLDC SIMPLIFIED BLDC MOTOR DIAGRAMS. Microchip Technology Inc. Brushless DC Motor Control Made Easy AN857 Author: Ward Brown Microchip Technology Inc. INTRODUCTION This application note discusses the steps of developing several controllers for brushless motors. We

More information

AN734. Using the PICmicro SSP for Slave I 2 C TM Communication INTRODUCTION THE I 2 C BUS SPECIFICATION

AN734. Using the PICmicro SSP for Slave I 2 C TM Communication INTRODUCTION THE I 2 C BUS SPECIFICATION Using the PICmicro SSP for Slave I 2 C TM Communication Author: INTRODUCTION Stephen Bowling Microchip Technology Incorporated Many devices in the PICmicro family have a Synchronous Serial Port (SSP) or

More information

PIC12F508/509/16F505 Data Sheet

PIC12F508/509/16F505 Data Sheet Data Sheet 8/14-Pin, 8-Bit Flash Microcontrollers 2009 Microchip Technology Inc. DS41236E Note the following details of the code protection feature on Microchip devices: Microchip products meet the specification

More information

PIC10F200/202/204/206 Data Sheet

PIC10F200/202/204/206 Data Sheet Data Sheet 6-Pin, 8-bit Flash Microcontrollers 2007 Microchip Technology Inc. DS41239D Note the following details of the code protection feature on Microchip devices: Microchip products meet the specification

More information

EE25M Introduction to microprocessors. Solutions & study tips. original author: Feisal Mohammed updated: 4th March 2002 CLR

EE25M Introduction to microprocessors. Solutions & study tips. original author: Feisal Mohammed updated: 4th March 2002 CLR EE25M Introduction to microprocessors original author: Feisal Mohammed updated: 4th March 2002 CLR C Solutions & study tips The solutions presented here should be consulted only AFTER you have attempted

More information

I 2 C Master Mode Overview and Use of the PICmicro MSSP I 2 C Interface with a 24xx01x EEPROM

I 2 C Master Mode Overview and Use of the PICmicro MSSP I 2 C Interface with a 24xx01x EEPROM I 2 C Master Mode Overview and Use of the PICmicro MSSP I 2 C Interface with a 24xx01x EEPROM v 0.40 Welcome to the Microchip Technology Presentation on using the MSSP module in Master I 2 C mode. In this

More information

AN657. Decoding Infrared Remote Controls Using a PIC16C5X Microcontroller INTRODUCTION HARDWARE DESCRIPTION THE THREE LAYERS OF AN INFRARED SIGNAL

AN657. Decoding Infrared Remote Controls Using a PIC16C5X Microcontroller INTRODUCTION HARDWARE DESCRIPTION THE THREE LAYERS OF AN INFRARED SIGNAL Decoding Infrared Remote Controls Using a PIC16C5X Microcontroller Author: William G. Grimm Consultant INTRODUCTION For many years the consumer electronics industry has been employing infrared remote controls

More information

Section 14. Compare/Capture/PWM (CCP)

Section 14. Compare/Capture/PWM (CCP) M Section 14. Compare/Capture/PWM (CCP) HIGHLIGHTS This section of the manual contains the following major topics: 14.1 Introduction...14-2 14.2 Control Register...14-3 14.3 Capture Mode...14-4 14.4 Compare

More information

Section 28. In-Circuit Serial Programming (ICSP )

Section 28. In-Circuit Serial Programming (ICSP ) M Section 28. In-Circuit Serial Programming (ICSP ) HIGHLIGHTS This section of the manual contains the following major topics: 28. Introduction...28-2 28.2 Entering In-Circuit Serial Programming Mode...28-3

More information

Memory organization. Memory blocks: Program memory (flash-type) 16 kword (32 kbyte) (instruction 16 bit wide) Data RAM 1536 byte (1.

Memory organization. Memory blocks: Program memory (flash-type) 16 kword (32 kbyte) (instruction 16 bit wide) Data RAM 1536 byte (1. TNE019 Mikrodatorer F2 1 Memory organization Memory blocks: Program memory (flash-type) 16 kword (32 kbyte) (instruction 16 bit wide) PC Reset Data RAM 1536 byte (1.5 kbyte) Data EEPROM 256 byte TNE019

More information

AN880. Converting from 8051 to Microchip Assembler: A Quick Reference INTRODUCTION

AN880. Converting from 8051 to Microchip Assembler: A Quick Reference INTRODUCTION Converting from 805 to Assembler: A Quick Reference Author: INTRODUCTION Gaurang Kavaiya Technology Inc. When migrating assembly language programs from one family of microcontrollers to another, the first

More information

PIC16F526 Data Sheet. 14-Pin, 8-Bit Flash Microcontroller. 2007 Microchip Technology Inc. Preliminary DS41326A

PIC16F526 Data Sheet. 14-Pin, 8-Bit Flash Microcontroller. 2007 Microchip Technology Inc. Preliminary DS41326A Data Sheet 14-Pin, 8-Bit Flash Microcontroller 2007 Microchip Technology Inc. Preliminary DS41326A Note the following details of the code protection feature on Microchip devices: Microchip products meet

More information

Quick Reference. B.5 12-Bit Core Instruction Set APPENDICES

Quick Reference. B.5 12-Bit Core Instruction Set APPENDICES Quic Reference B.5 12-Bit ore Instruction Set Microchip s base-line 8-bit microcontroller family uses a 12-bit wide instruction set. All instructions execute in a single instruction cycle unless otherwise

More information

AN215. A Simple CAN Node Using the MCP2515 and PIC12C672 SYSTEM DESCRIPTION INTRODUCTION. Overview DIAGRAM. Anadigics, Inc.

AN215. A Simple CAN Node Using the MCP2515 and PIC12C672 SYSTEM DESCRIPTION INTRODUCTION. Overview DIAGRAM. Anadigics, Inc. A Simple CAN de Using the MCP2515 and PIC12C672 Author: Rick Stoneking, Anadigics, Inc. INTRODUCTION This application note describes the design, development and implementation of a smart, low-cost, stand-alone

More information

PIC16F8X. 18-pin Flash/EEPROM 8-Bit Microcontrollers. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

PIC16F8X. 18-pin Flash/EEPROM 8-Bit Microcontrollers. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features: 18-pin Flash/EEPROM 8-Bit Microcontrollers Devices Included in this Data Sheet: PIC16F83 PIC16F84 PIC16CR83 PIC16CR84 Extended voltage range devices available (PIC16LF8X, PIC16LCR8X) High Performance RISC

More information

Call Subroutine (PC<15:0>) TOS, (W15)+2 W15 (PC<23:16>) TOS, Process data. Write to PC NOP NOP NOP NOP

Call Subroutine (PC<15:0>) TOS, (W15)+2 W15 (PC<23:16>) TOS, Process data. Write to PC NOP NOP NOP NOP Section 3. Descriptions CALL Call Subroutine Syntax: {label:} CALL lit23 CALL.S Operands: lit23 [0... 8388606] (PC)+4 PC, (PC) TOS, (W15)+2 W15 (PC) TOS, (W15)+2 W15 lit23 PC, NOP Register.

More information

EE282 Computer Architecture and Organization Midterm Exam February 13, 2001. (Total Time = 120 minutes, Total Points = 100)

EE282 Computer Architecture and Organization Midterm Exam February 13, 2001. (Total Time = 120 minutes, Total Points = 100) EE282 Computer Architecture and Organization Midterm Exam February 13, 2001 (Total Time = 120 minutes, Total Points = 100) Name: (please print) Wolfe - Solution In recognition of and in the spirit of the

More information

PROBLEMS (Cap. 4 - Istruzioni macchina)

PROBLEMS (Cap. 4 - Istruzioni macchina) 98 CHAPTER 2 MACHINE INSTRUCTIONS AND PROGRAMS PROBLEMS (Cap. 4 - Istruzioni macchina) 2.1 Represent the decimal values 5, 2, 14, 10, 26, 19, 51, and 43, as signed, 7-bit numbers in the following binary

More information

AN215. A Simple CAN Node Using the MCP2510 and PIC12C67X SYSTEM DESCRIPTION INTRODUCTION. Overview DIAGRAM. Anadigics, Inc.

AN215. A Simple CAN Node Using the MCP2510 and PIC12C67X SYSTEM DESCRIPTION INTRODUCTION. Overview DIAGRAM. Anadigics, Inc. M AN215 A Simple CAN de Using the MCP2510 and PIC12C67X Author: Rick Stoneking, Anadigics, Inc. SYSTEM DESCRIPTION Overview INTRODUCTION This application note describes the design, development and implementation

More information

NERD GIRLS Maximum Power Point Tracker

NERD GIRLS Maximum Power Point Tracker Nerd Girls Solar/MPPT Group May 12, 2003 1/66 Tufts University Department of Electrical Engineering and Computer Science NERD GIRLS Maximum Power Point Tracker Stephanie Chin Jeanell Gadson Katie Nordstrom

More information

6. Control Structures

6. Control Structures - 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,

More information

1. The demonstration code is sending garbage to my terminal program. What are the recommended settings?

1. The demonstration code is sending garbage to my terminal program. What are the recommended settings? HPC Explorer Demonstration Board Frequently Asked Questions and Troubleshooting Tips Dennis Lehman, Corporate Applications Engineer 09/16/2005 Here is a collection of common PICDEM HPC Explorer problems

More information

Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II

Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II Administration: o Prayer PicBasic Pro Programs Used in This Lesson: o General PicBasic Pro Program

More information

The stack and the stack pointer

The stack and the stack pointer The stack and the stack pointer If you google the word stack, one of the definitions you will get is: A reserved area of memory used to keep track of a program's internal operations, including functions,

More information

PIC12F510/16F506 Data Sheet

PIC12F510/16F506 Data Sheet Data Sheet 8/14-Pin, 8-Bit Flash Microcontrollers 2007 Microchip Technology Inc. DS41268D Note the following details of the code protection feature on Microchip devices: Microchip products meet the specification

More information

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes: Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes: An 8 or 16 bit microprocessor (CPU). A small amount of RAM. Programmable ROM and/or flash memory.

More information

c0003 A Simple PIC Application CHAPTER 3

c0003 A Simple PIC Application CHAPTER 3 c0003 CHAPTER 3 A Simple PIC Application Chapter Outline 3.1. Hardware Design 46 3.1.1. PIC 16F84A Pin-Out 46 3.1.2. BIN Hardware Block Diagram 47 3.1.3. BIN Circuit Operation 48 3.2. Program Execution

More information

Section 8. Interrupts

Section 8. Interrupts Interrupts M Section 8. Interrupts HIGHLIGHTS This section of the manual contains the following major topics: 8.1 Introduction...8-2 8.2 Control Registers...8-5 8.3 Interrupt Latency...8-10 8.4 INT and

More information

Keil C51 Cross Compiler

Keil C51 Cross Compiler Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation

More information

CC5X. C Compiler for the PIC Microcontrollers. User's Manual. Version 3.0. B. Knudsen Data Trondheim - Norway

CC5X. C Compiler for the PIC Microcontrollers. User's Manual. Version 3.0. B. Knudsen Data Trondheim - Norway CC5X C Compiler for the PIC Microcontrollers Version 3.0 User's Manual Trondheim - Norway This manual and the CC5X compiler is protected by Norwegian copyright laws and thus by corresponding copyright

More information

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features: M PIC6F84A 8-pin Enhanced Flash/EEPROM 8-Bit Microcontroller Devices Included in this Data Sheet: PIC6F84A Extended voltage range device available (PIC6LF84A) High Performance RISC CPU Features: Only 35

More information

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontroller Series. 2007 Microchip Technology Inc. DS41213D

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontroller Series. 2007 Microchip Technology Inc. DS41213D Data Sheet Flash-Based, 8-Bit CMOS Microcontroller Series 2007 Microchip Technology Inc. DS41213D Note the following details of the code protection feature on Microchip devices: Microchip products meet

More information

8085 INSTRUCTION SET

8085 INSTRUCTION SET DATA TRANSFER INSTRUCTIONS Opcode Operand Description 8085 INSTRUCTION SET INSTRUCTION DETAILS Copy from source to destination OV Rd, Rs This instruction copies the contents of the source, Rs register

More information

PIC12F519 Data Sheet. 8-Pin, 8-Bit Flash Microcontrollers

PIC12F519 Data Sheet. 8-Pin, 8-Bit Flash Microcontrollers Data Sheet 8-Pin, 8-Bit Flash Microcontrollers *8-bit, 8-pin devices protected by Microchip s Low Pin Count Patent: U.S. Patent No. 5,847,450. Additional U.S. and foreign patents and applications may be

More information

AN617. Fixed Point Routines FIXED POINT ARITHMETIC INTRODUCTION. Thi d t t d ith F M k 4 0 4. Design Consultant

AN617. Fixed Point Routines FIXED POINT ARITHMETIC INTRODUCTION. Thi d t t d ith F M k 4 0 4. Design Consultant Thi d t t d ith F M k 4 0 4 Fixed Point Routines AN617 Author: INTRODUCTION Frank J. Testa Design Consultant This application note presents an implementation of the following fixed point math routines

More information

PIC12F629/675 Data Sheet

PIC12F629/675 Data Sheet Data Sheet 8-Pin FLASH-Based 8-Bit CMOS Microcontrollers 2003 Microchip Technology Inc. DS41190C Note the following details of the code protection feature on Microchip devices: Microchip products meet

More information

HC12 Assembly Language Programming

HC12 Assembly Language Programming HC12 Assembly Language Programming Programming Model Addressing Modes Assembler Directives HC12 Instructions Flow Charts 1 Assembler Directives In order to write an assembly language program it is necessary

More information

M Floating Point to ASCII Conversion

M Floating Point to ASCII Conversion M Floating Point to ASCII Conversion AN670 Authors: INTRODUCTION It is often necessary to output a floating point number to a display. For example, to check calculations, one might want to output floating

More information

Section 9. I/O Ports

Section 9. I/O Ports I/O Ports M Section 9. I/O Ports HIGHLIGHTS This section of the manual contains the following major topics: 9.1 Introduction...9-2 9.2 PORTA and the TRISA Register...9-4 9.3 PORTB and the TRISB Register...9-6

More information

Section 44. CPU with Extended Data Space (EDS)

Section 44. CPU with Extended Data Space (EDS) Section 44. CPU with Extended Data Space (EDS) HIGHLIGHTS This section of the manual contains the following topics: 44.1 Introduction... 44-2 44.2 Programmer s Model... 44-5 44.3 Software Stack Pointer...

More information

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements 9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending

More information

The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway

The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway Abstract High Level Languages (HLLs) are rapidly becoming the standard

More information

MACHINE ARCHITECTURE & LANGUAGE

MACHINE ARCHITECTURE & LANGUAGE in the name of God the compassionate, the merciful notes on MACHINE ARCHITECTURE & LANGUAGE compiled by Jumong Chap. 9 Microprocessor Fundamentals A system designer should consider a microprocessor-based

More information

Introduction to PIC Programming

Introduction to PIC Programming Introduction to PIC Programming Baseline Architecture and Assembly Language by David Meiklejohn, Gooligum Electronics Lesson 1: Light an LED This initial exercise is the Hello World! of PIC programming.

More information

DEVELOPMENT OF A MICROCONTROLED IRRADIATION SYSTEM BASED ON LIGHT-EMITTING DIODES (LEDs) MATRIXES FOR PHOTOTHERAPY APPLICATIONS

DEVELOPMENT OF A MICROCONTROLED IRRADIATION SYSTEM BASED ON LIGHT-EMITTING DIODES (LEDs) MATRIXES FOR PHOTOTHERAPY APPLICATIONS DEVELOPMENT OF A MICROCONTROLED IRRADIATION SYSTEM BASED ON LIGHT-EMITTING DIODES (LEDs) MATRIXES FOR PHOTOTHERAPY APPLICATIONS Deborah Deah Assis Carneiro, Rafael Cruz Evangelista, Rozane de Fátima Turchiello,

More information

Embedded systems. chapter 7

Embedded systems. chapter 7 Embedded systems chapter 7 Embedded systems definition Embedded systems can be defined as systems that: directly control some hardware designed to a specific task only we will consider that an Embedded

More information

PIC16F84A Data Sheet. 18-pin Enhanced FLASH/EEPROM 8-bit Microcontroller. 2001 Microchip Technology Inc. DS35007B

PIC16F84A Data Sheet. 18-pin Enhanced FLASH/EEPROM 8-bit Microcontroller. 2001 Microchip Technology Inc. DS35007B M PIC16F84A Data Sheet 18-pin Enhanced FLASH/EEPROM 8-bit Microcontroller 2001 Microchip Technology Inc. DS35007B Note the following details of the code protection feature on PICmicro MCUs. The PICmicro

More information

M Floating Point to ASCII Conversion

M Floating Point to ASCII Conversion M Floating Point to ASCII Conversion AN670 Authors: INTRODUCTION It is often necessary to output a floating point number to a display. For example, to check calculations, one might want to output floating

More information

CoE3DJ4 Digital Systems Design. Chapter 4: Timer operation

CoE3DJ4 Digital Systems Design. Chapter 4: Timer operation CoE3DJ4 Digital Systems Design Chapter 4: Timer operation Timer There are two 16-bit timers each with four modes of operation Timers are used for (a) interval timing, (b) event counting or (c) baud rate

More information

PIC Application Notes

PIC Application Notes 4: Reading Rotary Encoders PIC Application Notes Reading Rotary Encoders Introduction. This application note covers the use of incremental rotary encoders with PIC microcontrollers. It presents an example

More information

SRF08 Ultra sonic range finder Technical Specification

SRF08 Ultra sonic range finder Technical Specification SRF08 Ultra sonic range finder Technical Specification Communication with the SRF08 ultrasonic rangefinder is via the I2C bus. This is available on popular controllers such as the OOPic and Stamp BS2p,

More information

The AT-PS/2 Keyboard Interface This article is Copyright 2001, Adam Chapweske

The AT-PS/2 Keyboard Interface This article is Copyright 2001, Adam Chapweske The AT-PS/2 Keyboard Interface This article is Copyright 2001, Adam Chapweske Introduction: This article tries to cover every aspect of the AT and PS/2 keyboards It includes information on the low-level

More information

Introduction to Microcontrollers

Introduction to Microcontrollers Introduction to Microcontrollers Motorola M68HC11 Specs Assembly Programming Language BUFFALO Topics of Discussion Microcontrollers M68HC11 Package & Pinouts Accumulators Index Registers Special Registers

More information

TB026. Calculating Program Memory Checksums Using a PIC16F87X ACCESSING MEMORY INTRODUCTION. PIC16C7X vs. PIC16F87X. Microchip Technology Inc.

TB026. Calculating Program Memory Checksums Using a PIC16F87X ACCESSING MEMORY INTRODUCTION. PIC16C7X vs. PIC16F87X. Microchip Technology Inc. M TB026 Calculating Program Memory Checksums Using a PIC16F87X Author: INTRODUCTION Many applications require the microcontroller to calculate a checksum on the program memory to determine if the contents

More information

PIC16F62X. FLASH-Based 8-Bit CMOS Microcontrollers. Devices included in this data sheet: Special Microcontroller Features: High Performance RISC CPU:

PIC16F62X. FLASH-Based 8-Bit CMOS Microcontrollers. Devices included in this data sheet: Special Microcontroller Features: High Performance RISC CPU: FLASH-Based 8-Bit CMOS Microcontrollers Devices included in this data sheet: PIC16F627 PIC16F628 Referred to collectively as PIC16F62X. High Performance RISC CPU: Only 35 instructions to learn All single-cycle

More information

LADDER LOGIC/ FLOWCHART PROGRAMMING DIFFERENCES AND EXAMPLES

LADDER LOGIC/ FLOWCHART PROGRAMMING DIFFERENCES AND EXAMPLES page 1/10 This document is designed as a quick-start primer to assist industrial automation programmers who are familiar with PLCs and Relay Ladder Logic programming to better understand the corresponding

More information

Programmer s Model = model of µc useful to view hardware during execution of software instructions

Programmer s Model = model of µc useful to view hardware during execution of software instructions HC12/S12 Programmer s Model Programmer s Model = model of µc useful to view hardware during execution of software instructions Recall: General Microcontroller/Computer Architecture note: Control Unit &

More information

PIC Lab Manual. PIC Lab Manual. 1 Include CD-ROM 2010/2011

PIC Lab Manual. PIC Lab Manual. 1 Include CD-ROM 2010/2011 PIC Lab Manual 2010/2011 1 Include CD-ROM Table Of Contents Experiment #1 Introduction to Software Tools MPLAB, PROTEUS, and QL-2006 programmer. Experiment #2 Introduction to PIC16F84A 6 3 Experiment #3

More information

Debugging of Application Programs on Altera s DE-Series Boards. 1 Introduction

Debugging of Application Programs on Altera s DE-Series Boards. 1 Introduction Debugging of Application Programs on Altera s DE-Series Boards 1 Introduction This tutorial presents some basic concepts that can be helpful in debugging of application programs written in the Nios II

More information

Translating C code to MIPS

Translating C code to MIPS Translating C code to MIPS why do it C is relatively simple, close to the machine C can act as pseudocode for assembler program gives some insight into what compiler needs to do what's under the hood do

More information

AN851. A FLASH Bootloader for PIC16 and PIC18 Devices INTRODUCTION FIRMWARE. Basic Operation BOOTLOADER FUNCTIONAL BLOCK DIAGRAM COMMUNICATIONS

AN851. A FLASH Bootloader for PIC16 and PIC18 Devices INTRODUCTION FIRMWARE. Basic Operation BOOTLOADER FUNCTIONAL BLOCK DIAGRAM COMMUNICATIONS A FLASH Bootloader for PIC16 and PIC18 Devices Author: Ross M. Fosler and Rodger Richey Microchip Technology Inc. FIGURE 1: BOOTLOADER FUNCTIONAL BLOCK DIAGRAM RX TX Bootloader Firmware INTRODUCTION Among

More information

PROBLEMS #20,R0,R1 #$3A,R2,R4

PROBLEMS #20,R0,R1 #$3A,R2,R4 506 CHAPTER 8 PIPELINING (Corrisponde al cap. 11 - Introduzione al pipelining) PROBLEMS 8.1 Consider the following sequence of instructions Mul And #20,R0,R1 #3,R2,R3 #$3A,R2,R4 R0,R2,R5 In all instructions,

More information

Distributed Synchronization

Distributed Synchronization CIS 505: Software Systems Lecture Note on Physical Clocks Insup Lee Department of Computer and Information Science University of Pennsylvania Distributed Synchronization Communication between processes

More information

PIC16F627A/628A/648A Data Sheet

PIC16F627A/628A/648A Data Sheet Data Sheet Flash-Based 8-Bit CMOS Microcontrollers with nanowatt Technology 2004 Microchip Technology Inc. Preliminary DS40044B Note the following details of the code protection feature on Microchip devices:

More information

Mini-ITX Power Solutions

Mini-ITX Power Solutions Micro DC-DC Converters & Automotive Applications Corp http://www.ituner.com andrewb@ituner.com v,1.1 07/14/2003 ab Contents Contents... 2 ITX, the Ultimate Form Factor... 3 The mini-itx Form Factor...

More information

Building A RISC Microcontroller in an FPGA

Building A RISC Microcontroller in an FPGA Building A RISC Microcontroller in an FPGA Name : Yap Zi He Course : 4 SEL Supervisor : PM Muhammad Mun im Ahmad Zabidi Introduction Reduce Instruction Set Computer (RISC) is a new trend on computer design.

More information

PIC16F627A/628A/648A Data Sheet

PIC16F627A/628A/648A Data Sheet Data Sheet Flash-Based, 8-Bit CMOS Microcontrollers with nanowatt Technology 2005 Microchip Technology Inc. DS40044D Note the following details of the code protection feature on Microchip devices: Microchip

More information

ELEG3924 Microprocessor Ch.7 Programming In C

ELEG3924 Microprocessor Ch.7 Programming In C Department of Electrical Engineering University of Arkansas ELEG3924 Microprocessor Ch.7 Programming In C Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Data types and time delay I/O programming and Logic operations

More information

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be... What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control

More information

Jonathan Worthington Scarborough Linux User Group

Jonathan Worthington Scarborough Linux User Group Jonathan Worthington Scarborough Linux User Group Introduction What does a Virtual Machine do? Hides away the details of the hardware platform and operating system. Defines a common set of instructions.

More information

MAX1781 Advanced Smart Battery-Pack Controller Features. General Description. Applications

MAX1781 Advanced Smart Battery-Pack Controller Features. General Description. Applications General Description The MAX1781 smart battery-pack controller integrates a user-programmable microcontroller core, a Coulombcounting fuel gauge, a multi-channel data-acquisition unit, and an SMBus v1.1

More information

Chapter 2 Assemblers http://www.intel.com/multi-core/demos.htm

Chapter 2 Assemblers http://www.intel.com/multi-core/demos.htm Chapter 2 Assemblers http://www.intel.com/multi-core/demos.htm Source Program Assembler Object Code Linker Executable Code Loader 1 Outline 2.1 Basic Assembler Functions A simple SIC assembler Assembler

More information

1 Description of The Simpletron

1 Description of The Simpletron Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies

More information

The Little Man Computer

The Little Man Computer The Little Man Computer The Little Man Computer - an instructional model of von Neuman computer architecture John von Neuman (1903-1957) and Alan Turing (1912-1954) each independently laid foundation for

More information

Lecture 22: C Programming 4 Embedded Systems

Lecture 22: C Programming 4 Embedded Systems Lecture 22: C Programming 4 Embedded Systems Today s Goals Basic C programming process Variables and constants in C Pointers to access addresses Using a High Level Language High-level languages More human

More information

Interrupts and the Timer Overflow Interrupts Huang Sections 6.1-6.4. What Happens When You Reset the HCS12?

Interrupts and the Timer Overflow Interrupts Huang Sections 6.1-6.4. What Happens When You Reset the HCS12? Interrupts and the Timer Overflow Interrupts Huang Sections 6.1-6.4 o Using the Timer Overflow Flag to interrupt a delay o Introduction to Interrupts o How to generate an interrupt when the timer overflows

More information

Instruction Set Architecture

Instruction Set Architecture Instruction Set Architecture Consider x := y+z. (x, y, z are memory variables) 1-address instructions 2-address instructions LOAD y (r :=y) ADD y,z (y := y+z) ADD z (r:=r+z) MOVE x,y (x := y) STORE x (x:=r)

More information

MICROPROCESSOR. Exclusive for IACE Students www.iace.co.in iacehyd.blogspot.in Ph: 9700077455/422 Page 1

MICROPROCESSOR. Exclusive for IACE Students www.iace.co.in iacehyd.blogspot.in Ph: 9700077455/422 Page 1 MICROPROCESSOR A microprocessor incorporates the functions of a computer s central processing unit (CPU) on a single Integrated (IC), or at most a few integrated circuit. It is a multipurpose, programmable

More information