ME 515 Mechatronics. A microprocessor

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

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

DERTS Design Requirements (1): Microcontroller Architecture & Programming

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

ME 6405 Introduction to Mechatronics

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

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

Embedded System Design

Professor E. Ambikairajah UNSW Sydney

Microcontrollers. Microcontroller

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

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming

Microcomputer Architecture and Programming

Learning Objectives:

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

PIC Discussion. By Eng. Tamar Jomaa

ME 475 Lab2 Introduction of PIC and Programming. Instructor: Zhen Wang

EEE111A/B Microprocessors

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

Introducing Microcontrollers System Design

Midrange 8b PIC Microcontrollers. ECE Senior Design 14 February 2017

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK

PIC 16F84A programming (II)

Microprocessors/Microcontrollers

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

Embedded Systems Design (630414) Lecture 1 Introduction to Embedded Systems Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

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


ELCT708 MicroLab Session #1 Introduction to Embedded Systems and Microcontrollers. Eng. Salma Hesham

Microcontroller Overview

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

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

Microcontroller systems Lec 2 PIC18LF8722 Microcontroller s s core

Chapter 2 Sections 1 8 Dr. Iyad Jafar

MICROPROCESSOR AND MICROCONTROLLER BASED SYSTEMS

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

Basic Components of Digital Computer

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

Lecture (04) PIC 16F84A programming I

Lecture (03) PIC16F84 (2)

The University of Texas at Arlington Lecture 3

AVR Microcontrollers Architecture

8051 Microcontrollers

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

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

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE:

Lecture (04) PIC16F84A (3)

Fig 1. Block diagram of a microcomputer

PIC Microcontroller Introduction

Introduction to Microcontrollers

Basics of Microprocessor

Figure 1.1: Some embedded device. In this course we shall learn microcontroller and FPGA based embedded system.

8051 Microcontroller

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER

Input/Output Ports and Interfacing

MT2 Introduction Embedded Systems. MT2.1 Mechatronic systems

History and Basic Processor Architecture

Flow Charts and Assembler Programs

b. List different system buses of 8085 microprocessor and give function of each bus. (8) Answer:

Physics 335 Intro to MicroControllers and the PIC Microcontroller

2. List the five interrupt pins available in INTR, TRAP, RST 7.5, RST 6.5, RST 5.5.

SOLUTIONS!! DO NOT DISTRIBUTE!!

Bolt 18F2550 System Hardware Manual

Introduction. Embedded system functionality aspects. Processing. Storage. Communication. Transformation of data Implemented using processors

Computer Hardware Requirements for Real-Time Applications

Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics

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

CREATED BY M BILAL & Arslan Ahmad Shaad Visit:

CONNECT TO THE PIC. A Simple Development Board

In this tutorial, we will discuss the architecture, pin diagram and other key concepts of microprocessors.

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

CENG-336 Introduction to Embedded Systems Development. Timers

Micro II and Embedded Systems

Micro computer Organization

Mark II Aiken Relay Calculator

ELEG3923 Microprocessor Ch.0 & Ch.1 Introduction to Microcontroller

Assembly Language Instructions

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

Chapter 4. MARIE: An Introduction to a Simple Computer

1 MALP ( ) Unit-1. (1) Draw and explain the internal architecture of 8085.

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

Chapter 1: Basics of Microprocessor [08 M]

Section 30. In-Circuit Serial Programming (ICSP )

Lecture (02) PIC16F84 (I)

MARIE: An Introduction to a Simple Computer

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

MICROCONTROLLERS 8051

EE 308: Microcontrollers

Microcontrollers. Introduction to the PIC 8-bit Midrange Family. ECE Senior Design 15 February 2017

UNIT V MICRO CONTROLLER PROGRAMMING & APPLICATIONS TWO MARKS. 3.Give any two differences between microprocessor and micro controller.

Department of Electronics and Instrumentation Engineering Question Bank

Pin Description, Status & Control Signals of 8085 Microprocessor

Transcription:

ME 515 Mechatronics Microcontroller Based Control of Mechanical Systems Asanga Ratnaweera Department of Faculty of Engineering University of Peradeniya Tel: 081239 (3627) Email: asangar@pdn.ac.lk A microprocessor Performs arithmetic and logic operations Receives digital input process according to stored program (variable) digital output Two main parts: arithmetic unit (AU) control unit (CU) 2 1

A microprocessor Arithmetic unit made up of: Arithmetic Logic Unit (ALU) arithmetic calculations + logic operations Accumulators (ACC) where arithmetic calculations are made Condition Code Register (CCR) set based on results of ALU; 4 common bits: Zero, Negative, Overflow, Carry 3 A microprocessor Control unit made up of: Memory Address Register (MAR) holds current address where µp is accessing Memory Data Register (MDR) holds instruction temporarily Program Counter (PC) holds next instruction address to be read from the program memory (flash memory). Generally the counter increments each time an instruction is executed Instruction Register (IR) The instruction at the address specified by the PC is read to this register. This operation is called a FETCH. Control Logic (CL) synchronisation 4 2

A microprocessor Instruction fletch cycle 5 Microcomputer system µp + memory + i/o chips = µcomputer system Memory devices store program, data I/O devices read input and/or display results Connected via buses. 3 types: Address (ex: 16-bit, unidirectional) Data (ex: 8-bit, bidirectional) Control (variable) e.g. Read, Write, Enable 6 3

Microcomputer system 8-bit data bus MPU ROM (program) RAM (data) PROGRAMMABLE I/O 16-bit address bus Control lines 7 Micro-controller Microcontrollers contain all of the functional sections (CPU, RAM, ROM, I/O, ports and timers) of a personal computer on a single integrated circuit. some people describe them as special purpose computers with several qualifying distinctions that separate them from other computers. Microcontrollers are "embedded" inside some other device (often a consumer product: kitchen appliances, TVs, VCRs, cameras, telephones) so that they can control the features or actions of the product. 8 4

Micro-controller 9 Building blocks of a microcontroller Memory unit Central Processing Unit Bus Input-output unit Serial communication Timer unit Watchdog Analog to Digital Converter 10 5

Building blocks: Input-output unit When working with ports, first of all it is necessary to choose which port we need to work with, and then to send data to, or take it from the port By selecting the appropriate register 11 Building blocks: Serial communication 12 6

Building blocks: Timer unit Timer unit can give information about time, duration, protocol etc. 13 Building blocks: Watchdog This timer watches over the normal operation of the microcontroller software. It must be regularly cleared by software. When it times out the microcontroller returns to the point in the program immediately after power on. This timer is used to recover program operation when the software has a defect (or bug). Even if the program is reinitialized the bug is still in the program. 14 7

Building blocks: Analog to Digital Converter Analog to Digital Converter is responsible for converting an information about some analog value to a binary number and for follow it through to a CPU block so that CPU block can further process it. Not available with all µp 15 Embedded Systems: General Block Diagram sensor sensor sensor Sensor conditioning Microcontroller (uc) Output interfaces actuator indicator 16 8

History in Brief 1959: first IC's 1971: µp 4004 4Bit Intel (~2000 Tr.) 1972: µp 8008 8Bit Intel (~5000 Tr.) 1974: µp 8080 8Bit Intel (~6000 Tr.) 1974: µp 6800 8Bit Motorola 1975: µp Z80 8Bit Zilog 1976: µp 9900 16Bit Texas Instruments 1978: µp 8086 16Bit Intel (50.000 Tr) 1982: µp 8286 16Bit Intel (100.000 Tr.) 1985: µp 80386 16Bit Intel (300.000 Tr.) 1989: µp 80486 16Bit Intel (106 Tr.) 1993: µp 80586 16Bit Intel (5 106 Tr.)... 17 Common Microcontrollers Families There are several families of microprocessors are widely used in industrial control systems Zilog Z8 series Intel 8051 series ARM 32 bit microcontrollers MicroChip PIC microcontrollers 18 9

PIC Range of low end 8 bit microcontrollers. smallest have only 8 pins, largest 40 pins. Typical chip is an 18 pin one. Very cheap, you can pick them up at less than Rs.500 each. Targeted at consumer products, burglar alarms etc. 19 20 10

PIC Microcontrollers The term PIC stands for Programmable Interface Controller. PIC microcontrollers have become very popular because Relatively cheap Small in size On chip memory Easy to program Reusable 21 PIC Microcontroller Architecture von Neumann architecture programs and data share a single memory area that is accessed over a common bus Harvard architecture separate memory areas and buses for data and programs von Neumann Architecture. Harvard Architecture. Note : PIC microcontroller follows Harvard design 22 11

PIC Microcontroller Characteristics CPUs 8-bit 16-bit Number of I/O pins: 4-70 Some chips have A/D converter and PWM Memory types and sizes: Flash; OTP; ROM 0.5k 256k 23 PIC Microcontrollers: Memory varieties Microchip produces field programmable microcontrollers in three basic varieties EPROM can be programmed electrically and erased, if needed, by a special ultraviolet light (window type) OTP can be programmed only once and is the least expensive of the three Flash can be both programmed and erased by electrical means 24 12

PIC Microcontrollers: Memory varieties Ex: 25 The PIC Family: Speed PICs require a clock to work. Can use crystals, clock oscillators, or even an RC circuit. Some PICs have a built in 4MHz RC clock Not very accurate, but requires no external components Instruction speed = 1/4 clock speed T cyc = 4 * T clk 13

The Minimum PIC System You need some kind of a clock: Internal 4MHz clock on some PICs, external RC, external crystal, or external clock oscillator. And you need some power: Most PICs can operate from 2.5V - 5.5V (see Data Sheets) New 16HVXX can directly use up to 14V (Great for direct 9V or 12V battery hook ups PIC Microcontrollers: Oscillator If the CPU is the brain of the system then the oscillator, or clock, is the heartbeat. It provides the critical timing functions for the rest of the chip. The original version of the 16F84 can operate at up to 4-MHz while the newer chip has a 20- MHz upper limit. This section of the PIC is extremely versatile. There are three principal ways to clock a PIC chip. 28 14

PIC Microcontrollers: Oscillator cont.. There are three principal ways to clock a PIC chip. Crystal controlled oscillator 29 PIC Microcontrollers: Oscillator cont.. RC oscillator Note: Not as precise as Xtal oscillator 30 15

PIC Microcontrollers: Oscillator cont.. External clock Note: This is useful when the chip must be synchronized with other components or an entire system must be operated from a single clock source 31 PIC Microcontrollers: PIC 16F84A PIC16F84A belongs to a class of 8-bit microcontrollers of RISC architecture. Its general structure is shown below. Microcontrollers with Harvard stands for. architecture are also called "RISC microcontrollers". RISC - Reduced Instruction Set Computer 32 16

PIC Microcontrollers: PIC 16F84A 33 PIC Microcontrollers: PIC 16F84 Program memory (FLASH) for storing a written program. Since memory made in FLASH technology can be programmed and cleared more than once, it makes this microcontroller suitable for device development. EEPROM - data memory that needs to be saved when there is no supply. RAM - data memory used by a program during its execution. In RAM are stored all inter-results or temporary data during run-time. 34 17

PIC Microcontrollers: PIC 16F84 PORTA and PORTB are physical connections between the microcontroller and the outside world. Port A has five, and port B has eight pins. FREE-RUN TIMER is an 8-bit register inside a microcontroller that works independently of the program. On every fourth clock of the oscillator it increments its value until it reaches the maximum (255), and then it starts counting over again from zero. CENTRAL PROCESSING UNIT The PIC has only 35 opcodes in its instruction set compared with more than 256 for a DEC Vax system6. 35 PIC 16F84 : Pin description PIC16F84 has a total of 18 pins. 36 18

PIC 16F84 : Pin description Pin Identifier RA[0-4] RB[0-7] V ss, V dd OSC1,OSC2 MCLR Description 5 bits of bidirectional I/O Port A 8 bits of bidirectional I/O Port B Power supply ground reference (ss source, dd drain) Oscillator crystal inputs Master clear, active low 37 PIC 16F84 A : Features Only 35 single word instructions to learn All instructions single-cycle except for program branches which are two-cycle Operating speed: 4 MHz clock input, 200 ns instruction cycle 1024 words of program memory 68 bytes of Data RAM 64 bytes of Data EEPROM 14-bit wide instruction words 8-bit wide data bytes 38 19

PIC 16F84A : Features 15 Special Function Hardware registers Eight-level deep hardware stack Direct, indirect and relative addressing modes Four interrupt sources: External RB0/INT pin TMR0 timer overflow PORTB<7:4> interrupt-on-change Data EEPROM write complete 39 PIC 16F84A : Peripheral Features 13 I/O pins with individual direction control High current sink/source for direct LED drive 25 ma sink max. per pin 25 ma source max. per pin TMR0: 8-bit timer/counter with 8-bit programmable prescaler 40 20

PIC 16F84A: Program memory The figure below shows the register file map inside the PIC16F84A 41 PIC 16F84 : Registers cont Bank 1 is used to control the actual operation of the PIC for example to tell the PIC which bits of Port A are input and which are output. Bank 0 is used to manipulate the data. To change from Bank 0 to Bank 1 we tell the STAUS register. We do this by setting bit 5 of the STATUS register to 1. To switch back to Bank 0, we set bit 5 of the STATUS register to 0. The STATUS register is located at address 03h (the h means the number is in Hexadecimal). 42 21

PIC16F877A : Features 5/6 Programming pins 8 A/D channels 2 Oscillator Inputs 2 RS-232 inputs 33 I/O ports 43 44 22

45 PIC Programming Language that microcontroller and man use to communicate is called "assembly language". Programs written in assembly language must be translated into a "language of zeros and ones" in order for a microcontroller to understand it (hex file). "Assembly language" and "assembler" are two different notions. The first represents a set of rules used in writing a program for a microcontroller, the other is a program on the personal computer which translates assembly language into a language of zeros and ones. A program that is translated into "zeros" and "ones" is also called "machine language". There are commercial software which could convert a C or Basic code in to PIC assembly language 46 23

PIC programming : Assembler The assembler expects to find specific terms in three columns. First column: Labels Second column: opcodes and assembler directives Third Columns & more: operands The three columns are used in five ways. Header section Equates section Origin section Program section The end statement. 47 PIC programming : Assembler Labels A label is a mnemonic symbol assigned to an address. Ex : portb means port B whose real hexadecimal address is 0x06. Rules for defining labels Must be positioned in the first column Must begin with an alpha character May contain numeric, underscore or question mark May be up to 31 characters 48 24

PIC programming : Assembler Literals Literals are constants or numbers, usually hexadecimal numbers. Ex: Literal start movlw 0x00 Label Instruction 49 PIC programming : Assembler Header Assembler directive list radix p=16f84 hex 50 25

PIC programming : Assembler Header The information at the top of the source file is called a header. ;=========== pict1.asm=========== list p=16f84 radix hex ;----------------------------------------------------------- first line defines the type of PIC to be used Second line says that the number system is hexadecimal 51 PIC programming : Assembler Equates Label This is an equates Hex address or number equ 52 26

PIC programming : Assembler Equates Equates are used to assign labels to addresses and names to numbers Hexadecimal address Ex: portb equ 0x06 Label Tells assembler this is an equate min equ 1 ; min =bit 1 flag equ 0x0c ; flag = file register 53 PIC programming : Assembler Origin Not used This is an origin Hex address org 54 27

PIC programming : Assembler Origin Usually origin statements used for three purposes. Defines where the program code starts org 0x000 To establish the reset vector org 0x1ff goto start To establish the start of an interupt service org 0x004 55 PIC programming : Assembler Program Label Instruction Literal or label org 56 28

PIC programming : Assembler End This is end end 57 PIC programming : Assembler Program format Standard header Equates Program End end 58 29

PIC programming : Assembler Assembler files All source code files must be saved with the file extension.asm. ex: pic_1.asm Assembler creates two from the source code.lst (assembler generated listing).hex (hexadecimal object code which can be downloaded to the chip) 59 PIC programming : Assembler The assembler program reads each text file line, ignores it if begins with a semicolon and steps through the three columns. Style list PIC16f84 radix hex portb equ 0x06 org 0x06 Start movlw 0x00 tris portb movewf portb circle goto circle end 60 30

PIC Programming The process of communication between a man and a microcontroller In order to do this we have to use a development system 61 Development Systems MPLAB C Compiler Assembly Simulate MPLAB SIM Program PRO MATE II PICSTART+ Edit Project MPLAB Emulate MPLAB-ICE PICMASTER ICEPIC 62 31

Development Systems MPLAB-ICE PICMASTER ICEPIC MPLAB-SIM PICSTART Plus PRO MATE II 63 Pin-1 Development Systems RS-232 Serial Interface PICSTART Plus DEVELOPMENT PROGRAMMER POWER ACTIVE 9V DC Input Power ON Programmer Active Upgrades done in MPLAB software - firmware upgrades occasionally required for new PICmicro sub-families Uses serial programming algorithms for all ICSP capable devices 40-Pin ZIF Socket to accommodate PICmicros from 8-8 to 40-pins. 68-pin PLCC can be programmed with an adapter 64 32

PIC16F84 8-bit RISC (35 instructions, pipelined) Program counter 13-bit (points to the current instruction, automatically incremented) Stack to support subroutines/interrupts can hold 8 levels of PC Memory Program memory (FLASH) 1024, 14-bit locations Data Memory RAM: 68, 8-bit locations EEPROM: 64, 8-bit locations (slow write access) 65 PIC programming : PIC16F84 instruction set PIC16F84 has 35 instruction in its instruction set Move or define data Note : k is a constant, f is the file register, d is destination-0 for w register and 1 for file register f Nothing 66 33

PIC programming : PIC16F84 instruction set PIC16F84 has 35 instruction in its instruction set Changing register content 67 PIC programming : PIC16F84 instruction set PIC16F84 has 35 instruction in its instruction set Control program flow 68 34

PIC programming : PIC16F84 instruction set PIC16F84 has 35 instruction in its instruction set Control Microcontroller 69 PIC programming : PIC16F84 instruction set PIC16F84 has 35 instruction in its instruction set Logic 70 35

PIC programming : PIC16F84 instruction set PIC16F84 has 35 instructions in its instruction set Arithmetic 71 Software: Programmers Model <- 12/14/16 bits -> Hardware Stack Stores addresses for subroutines Program Memory Burned in by programmer (can t change during execution). Stored instructions, addresses and literals (numbers). W Register (PCH) Program Counter-PCL <- 8 bits -> Status Special Purpose Registers I/O pin states, peripheral registers, etc. General Purpose Registers RAM or data memory. Variables are stored here. 36

Microcontroller Architecture 73 PIC16F84 : An Example Code Port configuration TRISA or TRISB are used to configure Port A and Port B respectively If a bit of TRSA is is high, corresponding pin of the Port A is configured as input, otherwise it is an output Ex: To configure pins 0 and 3 of Port A as outputs and 1 and 2 inputs BSF 03h,5 ;Go to Bank 1 MOVLW 06h ;Put 00110 (06h) into W MOVWF 85h ;Move 00110 onto TRISA BCF 03h,5 ;Come back to Bank 0 Note : see the memory map for the address, only the program section is shown 74 37

Software: Instruction Examples movlw 0xFF Move ( mov ) the number ( l for literal ) 0xFF - that s 256 in decimal- into the working register ( w ). In other words, load W with the value 0xFF. Software: Programmers Model <- 12/14/16 -> Program Memory (PCH) Hardware Stack Program Counter-PCL <- 8 bits -> Status Special Purpose Registers 0xFF W Register General Purpose Registers 38

Software: Instruction Examples PORTA 05h movwf PORTA Move ( mov ) the working register ( w ) into the file register ( f ) named PORTA. In other words, load the register called PORTA with whatever number is in the W register. Software: Programmers Model <- 12/14/16 -> Program Memory Value in W (PCH) Hardware Stack Program Counter-PCL <- 8 bits -> Status Special Purpose Registers PORTA W Register General Purpose Registers 39

Software: Instruction Examples movf PORTA, W Move ( mov ) the the value of the file register ( f ) named PORTA into the working register ( w ). In other words, load W with the whatever number is in PORTA. Software: Programmers Model <- 12/14/16 -> Program Memory (PCH) Hardware Stack Program Counter-PCL <- 8 bits -> Status Special Purpose Registers Value in PORTA PORTA W Register General Purpose Registers 40

Writing values to port A bcf 03h,5 ;Come back to Bank 0 Start movlw 02h ; Write 02h to the W register. In binary this is ; 00010, which puts a 1 on pin 2 while ; keeping ; the other pins to 0 movwf 05h ;Now move the contents of W (02h) oto the ;PortA, whose address is 05h movlw 00h ;Write 00h to the W register. This puts a 0 on ;all pins. movwf 05h ;Now move the contents of W (0h) onto the ;Port A whose address is 05h goto Start ;Go to where we say Start end 81 PIC16F84 : An Example Code STATUS equ 03h ;this assigns the word STATUS to the value of 03h, ;which is the address of the STATUS register. TRISA equ 85h ;This assigns the word TRISA to the value of 85h, ; which is the address of the Tri-State register for PortA PORTA equ 05h ;This assigns the word PORTA to 05h which is the ;address of Port A bsf 03h,5 ;Go to Bank 1 movlw 00h ;Put 00000 into W movwf 85h ;Move 00000 onto TRISA all pins set to output bcf 03h,5 ;Come back to Bank 0 Start movlw 02h ;Write 02h to the W register. In binary this is ;00010, which puts a 1 on pin 2 while keeping ;the other pins to 0 movwf PORTA ;Now move the contents of W (02h) onto the ;PortA, whose address is 05h movlw 00h ;Write 00h to the W register. This puts a 0 on ;all pins. movwf PORTA ;Now move the contents of W (0h) onto the Port A ; whose address is 05h 2 January 2007 goto end Start Asanga Ratnaweera, ;Go to where Department we say of Start 82 41

PIC16F84 : Hardware implementation 83 42