














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















; Author: John Cleveland ; Date : April 20, 2000 ; File Name: mod_led.asm ; PIC type: PIC16F ; Description: This is the model program for the first project in the ; PIC Lab. This program uses the PIC16F84 to turn on an ; LED at port RA0. ;********************************************************************** ; list p=16f84 ;tells which PIC to be used: PIC16F radix hex ;to use hex notation ; ;********************************************************************** ;Declarations porta equ 0x05 ;now file register 05 labeled porta ; org 0x000 ;start executing instructions from ; first address ; Init movlw 0x00 ;set up I/O for porta: RA0 as output, tris porta ;RA1 - RA3 not connected ; Main movlw 0x movwf porta ;turn on LED goto Main ;keep LED on end
; Author: John Cleveland ; Date : April 20, 2000 ; File Name: mod_but.asm ; PIC type: PIC16F ; Description: This is the model program for the second project in the ; PIC Lab. This program uses the PIC16F84 to turn on an ; LED at port pin RA0 when a push button is pressed. ;********************************************************************** ; list p=16f84 ;tells which PIC to be used: PIC16F radix hex ;to use hex notation ; ;********************************************************************** ;Declarations porta equ 0x05 ;now file register 05 labeled porta portb equ 0x06 ;not file register 06 labeled portb ; org 0x000 ;start executing instructions from ; first address ; Init movlw 0x00 ;set up I/O for porta: RA0 as output, tris porta ;RA1 - RA3 not connected movlw 0xff ;set up I/O for portb: RB0 as input, tris portb ;RB1 - RB7 not connected ; Main movfw portb ;read portb, put result in working ; register movwf porta ;turn on LED goto Main ;keep sensing when button is pressed end
call delay call delay call delay call delay ;waits for two seconds movlw 00010001 movwf portb ;motorist red on, ped green on, red off call delay call delay call delay call delay call delay call delay call delay call delay call delay call delay call delay call delay call delay call delay call delay ;wait for five seconds movlw 00010010 movwf portb ;turn on motorist yellow, red off movlw 0x movwf count5 ;load count5 with the number 5 Flash movlw 00010010 ;this routine flashes the ped green LED movwf portb call delay call delay ;keep ped green on for half second movlw 00000010 movwf portb call delay call delay ;turn green off for half second decfszcount5 ;makes ped green LED blink on and off ; five times goto Flash goto Main ;loop back to main to sense when button ; is pressed end
The following is an explanation of the instructions used in this lab. This is not the complete instruction set for the PIC chip. There are 35 instructions in the complete set.
call subroutine calls a subroutine
decfsz fileRegister decrements the number in the file register and puts the result back into the same file register
goto k go to a specified address or label
movlw k loads the working register with a number
movfw fileRegister copies contents of selected register into working register
movwf fileRegister copies contents of working register into selected file register
return returns from a subroutine
tris fileRegister working register bit pattern determines port line input vs. output