You are on page 1of 8

SCHEMATIC DIAGRAM

list p=16F84A ; list directive to define processor


#include <p16F84A.inc> ; processor specific variable definitions

__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC

; '__CONFIG' directive is used to embed configuration data within .asm file.


; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.

;***** VARIABLE DEFINITIONS

w_temp EQU 0x0C ; variable used for context saving

status_temp EQU 0x0D ; variable used for context saving

STATUS equ 03h ; this assigns the word Status to the value of 03h,
; which is the address of the Status register.
TRISB equ 86h ; This assigns the word TRISB to the value of 86h,
; which is the address of the Tri-State register for PortB
PORTB equ 06h ; This assigns the word PORTB to 06h which is the
; address of Port B.
COUNT1 equ 08h ; First counter for our delay loops
COUNT2 equ 09h ; Second counter for our delay loops
COUNT3 equ 10h ; Third counter for our delay loop
COUNT4 equ 11h ; Fourth counter for our delay loop
COUNT5 equ 12h ; Fifth counter for our delay loop
COUNT6 equ 13h ; Sixth counter for our delay loop
COUNT7 equ 14h ; Seventh counter for our delay loop
COUNT8 equ 15h ; Eighth counter for our delay loop
COUNT9 equ 16h ; Ninth counter for our delay
COUNT10 equ 17h ; Tenth counter for our delay

;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program

ORG 0x004 ; interrupt vector location


movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register

; isr code can go here or be located as a call subroutine elsewhere

movf status_temp,w ; retrieve copy of STATUS register


movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt

main

; remaining code goes here

;****Set up the Port****

bsf STATUS,RP0 ; Go to Bank 1


movlw 00h ; Put 00000 into W
movwf TRISB ; Move 00000 onto TRISB
bcf STATUS,RP0 ; Come back to Bank 0

;****Turn all LED on****

Start
call CW
call CW
call CW
call CW
call CW
call CW
call CW
call CW
call CW
call CW ;10th

call CW
call CW
call CW
call CW
call CW
call CW
call CW
call CW
call CW
call CW ;20th

call CW
call CW
call CW
call CW
call CW
call CW
call CW
call CW
call CW
call CW ;30th
call CW
call CW
call CW
call CW
call CW
call CW ;36th

call Delay2sec

call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW ;10th

call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW ;20th
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW
call CCW ;30th

call CCW
call CCW
call CCW
call CCW
call CCW
call CCW ;36th

call Delay2sec

goto Start

CCW
movlw b'00000001'
movwf PORTB
call DelayFast
movlw b'00010000'
movwf PORTB
call DelayFast
movlw b'00001000'
movwf PORTB
call DelayFast
movlw b'00000010'
movwf PORTB
call DelayFast
return
CW
movlw b'00000010'
movwf PORTB
call DelaySlow
movlw b'00001000'
movwf PORTB
call DelaySlow
movlw b'00010000'
movwf PORTB
call DelaySlow
movlw b'00000001'
movwf PORTB
call DelaySlow
return
Delay2sec

movlw D'12'
movwf COUNT1
movlw D'24'
movwf COUNT2
movlw D'167'
movwf COUNT3
Loop
decfsz COUNT3,1
goto Loop
decfsz COUNT2,1
goto Loop
decfsz COUNT1,1
goto Loop
return
DelaySlow
movlw D'6'
movwf COUNT4
movlw D'24'
movwf COUNT5
movlw D'167'
movwf COUNT6
Loop1
decfsz COUNT6,1
goto Loop1
decfsz COUNT5,1
goto Loop1
decfsz COUNT4,1
goto Loop1
return
DelayFast
movlw D'3'
movwf COUNT8
movlw D'24'
movwf COUNT9
movlw D'167'
movwf COUNT10
Loop2
decfsz COUNT10,1
goto Loop2
decfsz COUNT9,1
goto Loop2
decfsz COUNT8,1
goto Loop2
return
END

You might also like