Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

Similar documents
Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

Laboratory Exercise 5 - Analog to Digital Conversion

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

Flow Charts and Assembler Programs

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

Chapter 5 Sections 1 6 Dr. Iyad Jafar

Assembly Language Instructions

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

Binary Outputs and Timing

Lecture (04) PIC16F84A (3)

PIC 16F84A programming (II)

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

ECE Test #1: Name

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

Arithmetic,logic Instruction and Programs

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

SOLUTIONS!! DO NOT DISTRIBUTE!!

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE Microcontroller Based System Design

D:\PICstuff\PartCounter\PartCounter.asm

Week1. EEE305 Microcontroller Key Points

EEE111A/B Microprocessors

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

ALU and Arithmetic Operations

Appendix D: Source Codes. PDF created with pdffactory Pro trial version

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

EECE.3170: Microprocessor Systems Design I Spring 2016

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

Performance & Applications

Instuction set

Chapter 13. PIC Family Microcontroller

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Chapter 3: Further Microcontrollers

PIC Architecture & Assembly Language Programming. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

A Better Mouse Trap. Consumer Appliance, Widget, Gadget APPLICATION OPERATION: Ontario, Canada

Embedded System Design

Embedded Systems Programming and Architectures

Experiment 7:The USART

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

16.317: Microprocessor-Based Systems I Spring 2012

Input/Output Ports and Interfacing

CONNECT TO THE PIC. A Simple Development Board

Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011

Introduction to PIC Programming

Micro II and Embedded Systems

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

Self-Contained Electro Myograph. University of Alberta EE 401

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

Application Note - PIC Source Code v1.1.doc

PART TWO LISTING 8 PROGRAM TK3TUT8 MOVF PORTA,W ANDLW B ADDWF COUNT,F MOVF COUNT,W MOVWF PORTB GOTO LOOP

16.317: Microprocessor-Based Systems I Summer 2012

EECE.3170: Microprocessor Systems Design I Summer 2017

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

Arithmetic and Logic Instructions. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

PIC Discussion. By Eng. Tamar Jomaa

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

ECE Homework #3

Lesson 7 Multiple Precision Arithmetic

THE UNIVERSITY OF THE WEST INDIES

LPTCOM. Bruce Misner Lakehead University h d3 RD2 pin 21. RD3 pin h d4. RD4 pin 27 RD5 pin h d5. RD6 pin 29 RD7 pin H d6

movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt

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

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

DERTS Design Requirements (1): Microcontroller Architecture & Programming

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

16.317: Microprocessor Systems Design I Fall 2015

PTK8756B 8 Bit Micro-controller Data Sheet

ECE 354 Introduction to Lab 2. February 23 rd, 2003

16.317: Microprocessor Systems Design I Fall Exam 3 December 15, Name: ID #:

The University of Texas at Arlington Lecture 5

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

Done 1 NVB THF TLF T/R POL 1SHOT. Figure 1: Status register

More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller

USER S MANUAL VERSION June, KB1 AT-PS/2 Keyboard Interface Chip

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

Chapter 3 BRANCH, CALL, AND TIME DELAY LOOP

Discrete Logic Replacement Message Dispatch Engine

Lab-Report Microprocessors

Fortune. Semiconductor Corporation 富晶半導體股份有限公司. 8-bit MCU with 1k program ROM, 64-byte RAM, 1 R2F module and 3 13 LCD driver. TD Rev. 1.

S w e d i s h c r. w e e b l y. c o m j a l i l a h m e l i v e. c o m Page 1

Section 4. Architecture

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

ﻢﯿﺣﺮﻟا ﻦﻤﺣﺮﻟا ﷲا ﻢﺴﺑ

Beacon Keyers Using PIC s. Dave Powis, DL/G4HUP

GUIDE TO USE OF PIC 16F690 EEProm. The 16F690 PIC has a 256 byte EEProm (mapped to 0x x21FF).

AN719. Interfacing Microchip s MCP3201 Analog-to-Digital Converter to the PICmicro Microcontroller INTRODUCTION

EEE394 Microprocessor and Microcontroller Laboratory Lab #6

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

Chapter 5. Problems All programming problems should include design pseudo code either as a separate design document on embedded comments in the code.

Transcription:

Interfacing PIC Microcontrollers ADC8BIT2 Schematic This application demonstrates analogue input sampling A manually adjusted test voltage 0-5V is provided at AN0 input A reference voltage of 2.56V is provided at VREF+, setting the conversion range and resolution (10mV per bit) The internal analogue to digital converter produces an 8-bit code representing the voltage This is converted to 3 digit BCD and each digit converted to ASCII for output to the LCD

ADC8BIT2 Source Code Project: ADC8BIT2 Devised by: MPB Date: 14-01-13 Status: Updated for VSM v8 Demonstrates simple analogue input using an external reference voltage of 2.56V The 8-bit result is converted to BCD for display as a voltage using the standard LCD routines. PROCESSOR 16F877A Clock = XT 4MHz, standard fuse settings CONFIG 0x3731 LABEL EQUATES #INCLUDE "P16F877A.INC" standard labels GPR 70-75 allocated to included LCD display routine count EQU 30 Counter for ADC setup delay ADbin EQU 31 Binary input value huns EQU 32 Hundreds digit in decimal value tens EQU 33 Tens digit in decimal value ones EQU 34 Ones digit in decimal value PROGRAM BEGINS CODE 0 Default start address NOP required for ICD mode Port & display setup... BANKSEL TRISC Select bank 1 CLRF TRISD Display port is output MOVLW B'00000011' Analogue input setup code MOVWF ADCON1 Left justify result, Port A = analogue inputs BANKSEL PORTC Select bank 0 CLRF PORTD Clear display outputs MOVLW B'01000001' Analogue input setup code MOVWF ADCON0 f/8, RA0, done, enable MAIN LOOP start CALL getadc read input CALL condec convert to decimal CALL putlcd display input GOTO start jump to main loop SUBROUTINES Read ADC input and store... getadc BSF ADCON0,GO start ADC.. wait BTFSC ADCON0,GO..and wait for finish GOTO wait MOVF ADRESH,W store result high byte Convert input to decimal... condec MOVWF ADbin get ADC result CLRF huns zero hundreds digit CLRF tens zero tens digit CLRF ones zero ones digit Calclulate hundreds... BSF STATUS,C set carry for subtract MOVLW D'100' load 100 sub1 SUBWF ADbin and subtract from result INCF huns count number of loops BTFSC STATUS,C and check if done GOTO sub1 no, carry on ADDWF ADbin yes, add 100 back on DECF huns and correct loop count Calculate tens digit... BSF STATUS,C repeat process for tens MOVLW D'10' load 10 sub2 SUBWF ADbin and subtract from result INCF tens count number of loops BTFSC STATUS,C and check if done GOTO sub2 no, carry on ADDWF ADbin yes, add 100 back on DECF tens and correct loop count MOVF ADbin,W load remainder MOVWF ones and store as ones digit CALL inid Initialise the display done

ADC8BIT2 Source Code Output to display... putlcd BCF Select,RS set display command mode MOVLW 080 code to home cursor CALL send output it to display BSF Select,RS and restore data mode Convert digits to ASCII and display... MOVLW 030 load ASCII offset ADDWF huns convert hundreds to ASCII ADDWF tens convert tens to ASCII ADDWF ones convert ones to ASCII MOVF huns,w load hundreds code CALL send and send to display MOVLW '.' load point code MOVF tens,w load tens code MOVF ones,w load ones code MOVLW ' ' load space code MOVLW 'V' load volts code MOVLW 'o' load volts code MOVLW 'l' load volts code MOVLW 't' load volts code MOVLW 's' load volts code INCLUDED ROUTINES Include LCD driver routines #INCLUDE "LCD.INC" Contains routines: inid: Initialises display onems: 1 ms delay xms: X ms delay Receives X in W send: Sends a character to display Receives: Control code in W (Select,RS=0) ASCII character code in W (RS=1) END done

Interfacing PIC Microcontrollers ADC10BIT2 Schematic This application demonstrates high resolution 10-bit ADC input handling The reference voltage is 4.096V, giving a conversion factor of 4mV per bit The ADC binary output of 0 1024 is converted into 4 digit BCD This is converted to ASCII and sent to the LCD The measurement precision is better than 0.1%

ADC10BIT2 Source Code Project: ADC10BIT2 Devised by: MPB Date: 14-01-13 Status: Updated for VSM v8 Demonstrates 10-bit voltage measurement using an external reference voltage of 4.096V, giving 4mV per bit, and an resolution of 0.1%. The result is converted to BCD for display as a voltage using the standard LCD routines. PROCESSOR 16F877 Clock = XT 4MHz, standard fuse settings CONFIG 0x3731 LABEL EQUATES INCLUDE "P16F877A.INC" standard register labels User register labels GPR 20-2F allocated to included LCD display routine count EQU 30 Counter for ADC setup delay ADhi EQU 31 Binary input high byte ADlo EQU 32 Binary input low byte thos EQU 33 Thousands digit in decimal huns EQU 34 Hundreds digit in decimal value tens EQU 35 Tens digit in decimal value ones EQU 36 Ones digit in decimal value PROGRAM BEGINS CODE 0 Default start address NOP required for ICD mode Port & display setup BANKSEL TRISD Select bank 1 CLRF TRISD Display port is output MOVLW B'10000011' Analogue input setup code MOVWF ADCON1 Right justify result, Port A = analogue inputs with external reference BANKSEL PORTD Select bank 0 CLRF PORTD Clear display outputs MOVLW B'01000001' Analogue input setup code MOVWF ADCON0 f/8, RA0, done, enable CALL inid Initialise the display MAIN LOOP start CALL getadc read input CALL con4 convert to decimal CALL putlcd display input GOTO start jump to main loop

ADC10BIT2 Source Code - SUBROUTINES - Read ADC input and store - getadc MOVLW 007 load counter MOVWF count down DECFSZ count and delay 20us GOTO down BSF ADCON0,GO start ADC.. wait BTFSC ADCON0,GO..and wait for finish GOTO wait - Convert 10-bit input to decimal - con4 MOVF ADRESH,W get ADC result MOVWF ADhi high bits BANKSEL ADRESL in bank 1 MOVF ADRESL,W get ADC result BANKSEL ADRESH default bank 0 MOVWF ADlo low byte Multiply by 4 for result 0-4096 by shifting left... BCF STATUS,C rotate 0 into LSB and RLF ADlo shift low byte left BTFSS STATUS,C carry out? GOTO rot1 no, leave carry clear BSF STATUS,C rotate 1 into LSB and rot1 RLF ADhi shift high byte left BCF STATUS,C rotate 0 into LSB RLF ADlo rotate low byte left again BTFSS STATUS,C carry out? GOTO rot2 no, leave carry clear BSF STATUS,C rotate 1 into LSB and rot2 RLF ADhi shift high byte left Clear BCD registers... clrbcd CLRF thos zero thousands digit CLRF huns zero hundreds digit CLRF tens zero tens digit CLRF ones zero ones digit Calclulate thousands low byte... tholo MOVF ADhi,F check high byte BTFSC STATUS,Z high byte zero? GOTO hunlo yes, next digit BSF STATUS,C set carry for subtract MOVLW 0E8 load low byte of 1000 SUBWF ADlo and subtract low byte BTFSC STATUS,C borrow from high bits? GOTO thohi no, do high byte DECF ADhi yes, subtract borrow Calculate thousands high byte... thohi BSF STATUS,C set carry for subtract MOVLW 003 load high byte of 1000 SUBWF ADhi subtract from high byte BTFSC STATUS,C result negative? GOTO incth no, inc digit and repeat ADDWF ADhi yes, restore high byte Restore remainder when done... BCF STATUS,C clear carry for add MOVLW 0E8 load low byte of 1000 ADDWF ADlo add to low byte BTFSC STATUS,C carry out? INCF ADhi yes, inc high byte GOTO hunlo and do next digit Increment thousands digit and repeat... incth INCF thos inc digit GOTO tholo and repeat

ADC10BIT2 Source Code Convert digits to ASCII and display... Calclulate hundreds... hunlo MOVLW 064 load 100 BSF STATUS,C set carry for subtract SUBWF ADlo and subtract low byte BTFSC STATUS,C result negative? GOTO inch no, inc hundreds & repeat MOVF ADhi,F yes, test high byte BTFSC STATUS,Z zero? GOTO remh yes, done DECF ADhi no, subtract borrow inch INCF huns inc hundreds digit GOTO hunlo and repeat remh ADDWF ADlo restore onto low byte Calculate tens digit... subt MOVLW D'10' load 10 BSF STATUS,C set carry for subtract SUBWF ADlo and subtract from result BTFSS STATUS,C and check if done GOTO remt yes, restore remainder INCF tens no, count number of loops GOTO subt and repeat Restore remainder... remt ADDWF ADlo yes, add 10 back on MOVF ADlo,W load remainder MOVWF ones and store as ones digit done - Output to display - putlcd BCF Select,RS set display command mode MOVLW 080 code to home cursor CALL send output it to display BSF Select,RS and restore data mode MOVLW 030 load ASCII offset ADDWF thos convert thousands to ASCII ADDWF huns convert hundreds to ASCII ADDWF tens convert tens to ASCII ADDWF ones convert ones to ASCII MOVF thos,w load thousands code CALL send and send to display MOVLW '.' load point code MOVF huns,w load hundreds code CALL send and send to display MOVF tens,w load tens code MOVF ones,w load ones code MOVLW ' ' load space code MOVLW 'V' load volts code MOVLW 'o' load volts code MOVLW 'l' load volts code MOVLW 't' load volts code MOVLW 's' load volts code done INCLUDED ROUTINES Include LCD driver routine INCLUDE "LCD.INC" Contains routines: init: Initialises display onems: 1 ms delay xms: X ms delay Receives X in W send: sends a character to display Receives: Control code in W (Select,RS=0) ASCII character code in W (RS=1) END of source code

Interfacing PIC Microcontrollers AMPS2 Schematic This application demonstrates a range of op-amp interface configurations using the low resolution voltage display (0-2.55V) The operating characterisitics of the inverting, non-inverting, summing, difference and unity gain buffer are illustrated by the simulated output values The exact gain, output voltage offset and external currents associated with each configuration using the LM324 op-amp can be evaluated

AMPS2 Source Code Project: AMPS2 Devised by: MPB Date: 14-01-13 Status: Updated for VSM v8 Displays input from different amplifier types PROCESSOR 16F877A Clock = XT 4MHz, standard fuse settings CONFIG 0x3731 LABEL EQUATES INCLUDE "P16F877A.INC" standard register labels User register labels GPR 20-2F allocated to included LCD display routine count EQU 30 Counter for ADC setup delay ADbin EQU 31 Binary input value huns EQU 32 Hundreds digit in decimal value tens EQU 33 Tens digit in decimal value ones EQU 34 Ones digit in decimal value PROGRAM BEGINS CODE 0 Default start address NOP required for ICD mode Port & display setup BANKSEL TRISC Select bank 1 CLRF TRISD Display port is output MOVLW B'00000011' Analogue input setup code MOVWF ADCON1 Left justify result, Port A = analogue inputs BANKSEL PORTC Select bank 0 CLRF PORTD Clear display outputs MOVLW B'01000001' Analogue input setup code MOVWF ADCON0 f/8, RA0, done, enable MAIN LOOP start CALL getadc read input CALL condec convert to decimal CALL putlcd display input GOTO start jump to main loop - SUBROUTINES - Read ADC input and store... getadc BSF ADCON0,GO start ADC.. wait BTFSC ADCON0,GO..and wait for finish GOTO wait MOVF ADRESH,W store result, high 8 bits - Convert input to decimal condec MOVWF ADbin get ADC result CLRF huns zero hundreds digit CLRF tens zero tens digit CLRF ones zero ones digit Calclulate hundreds... BSF STATUS,C set carry for subtract MOVLW D'100' load 100 sub1 SUBWF ADbin and subtract from result INCF huns count number of loops BTFSC STATUS,C and check if done GOTO sub1 no, carry on ADDWF ADbin yes, add 100 back on DECF huns and correct loop count Calculate tens digit... BSF STATUS,C repeat process for tens MOVLW D'10' load 10 sub2 SUBWF ADbin and subtract from result INCF tens count number of loops BTFSC STATUS,C and check if done GOTO sub2 no, carry on ADDWF ADbin yes, add 100 back on DECF tens and correct loop count MOVF ADbin,W load remainder MOVWF ones and store as ones digit done CALL inid Initialise the display

AMPS2 Source Code - Output to display putlcd BCF Select,RS set display command mode MOVLW 080 code to home cursor CALL send output it to display BSF Select,RS and restore data mode Convert digits to ASCII and display... MOVLW 030 load ASCII offset ADDWF huns convert hundreds to ASCII ADDWF tens convert tens to ASCII ADDWF ones convert ones to ASCII MOVF huns,w load hundreds code CALL send and send to display MOVLW '.' load point code MOVF tens,w load tens code MOVF ones,w load ones code MOVLW ' ' load space code MOVLW 'V' load volts code MOVLW 'o' load volts code MOVLW 'l' load volts code MOVLW 't' load volts code MOVLW 's' load volts code INCLUDED ROUTINES Include LCD driver routine INCLUDE "LCD.INC" Contains routines: init: Initialises display onems: 1 ms delay xms: X ms delay Receives X in W send: sends a character to display Receives: Control code in W (Select,RS=0) ASCII character code in W (RS=1) END of source code done

Interfacing PIC Microcontrollers INSTAMP2 Schematic This application demonstrates an interface for an instumentation amplifier A small differential input voltage up to 25mV is fed to an input stage with a gain of 100 The output differential unity gain amplifier gives a single ended output of 0-2.5V The display MCU and LCD use the same firmware as the application AMPS2

Interfacing PIC Microcontrollers DACS2 Schematic This application demonstrates analogue output The parallel DAC receives an 8-bit input and produces a proportionate analogue output current that is converted to to voltage in the output buffer The serial DAC receives an SPI serial data input containing a 16-bit code that it converts to a corresponding anlogue voltage output The outputs are incremented and decremented via the push buttons

DACS2 Source Code Check buttons ------------------------------------ *************************************************** DACS2.ASM MPB 18-01-13 Test program for parallel and serial D/A Converters DAC0808 & MCP4921 Updated for VSM v8 *************************************************** PROCESSOR 16F877A INCLUDE "P16F877A.INC" CONFIG 0X3731 Hibyte EQU 020 SPI data high byte Lobyte EQU 021 SPI data low byte CODE 0 NOP Load at default range for ICD operations Initialise parallel and serial ports ------------- BANKSEL TRISD CLRF TRISD Parallel port BCF TRISC,5 Serial data BCF TRISC,3 Serial clock BCF TRISC,0 Chip select CLRF SSPSTAT default SPI mode BANKSEL PORTD CLRF PORTD zero PDAC CLRF SSPCON default SPI mode MOVLW B'00111001' Initial SDAC data MOVWF Hibyte and store MOVLW B'11111111' MOVWF Lobyte up BTFSC PORTB,1 Test UP button GOTO down and jump if off INCF PORTD Increment PDAC INCF Hibyte Increment SDAC waitup BTFSS PORTB,1 Wait for.. GOTO waitup button release down BTFSC PORTB,2 Test DOWN button GOTO spi and jump if off DECF PORTD Decrement PDAC DECF Hibyte Decrement SDAC waitdo BTFSS PORTB,2 Wait for.. GOTO waitdo button release Send 16-bit data to SDAC via SPI port ------------ spi BSF SSPCON,SSPEN Enable SPI port BCF PORTC,0 Enable SDAC chip MOVF Hibyte,W Get high data MOVWF SSPBUF and send it waithi BTFSS PIR1,SSPIF Wait for.. GOTO waithi SPI interrupt BCF PIR1,SSPIF Reset interrupt MOVF Lobyte,W Get low data MOVWF SSPBUF and send it waitlo BTFSS PIR1,SSPIF Wait for.. GOTO waitlo SPI interrupt BCF PIR1,SSPIF Reset interrupt BSF PORTC,0 Disable SDAC chip Run output loop until reset --------------------- BTFSC PORTB,0 Test run button GOTO up and repeat loop run INCF PORTD Increment PDAC GOTO run END ---------------------------------------