;PIC Christmas Pattern Lights
;Peter 2007
LIST p=16F628 ;tell assembler what chip we are using
#include "P16F628.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings
;(oscillator type etc.)
;Constants
COUNT1 equ 020h ;First counter for our delay loops
Timer1 equ 021h ;Second counter for our delay loops
org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB all outputs
movwf TRISB
movlw b'00000000'
movwf TRISA ;set PortA all outputs
bcf STATUS, RP0 ;select bank 0
movlw 255 ;First put the value of 85h in the W register
movwf 020h ;Now move it to our 08h register.
movlw 85h ;First put the value of 85h in the W register
movwf 020h ;Now move it to our 08h register.
Main
Pat1 MOVLW 01H ; Set the first bit
MOVWF PORTB ; on Port B.
RLF PORTB,1 ;Pattern to shift Lights left
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RRF PORTA,1 ;Pattern to shift Lights Right
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
Rpt decfsz Timer1,1 ;This second loop keeps the LED
goto Pat1
goto end
Delay
Loop1 decfsz COUNT1,F ;This second loop keeps the LED
goto Loop1 ;turned off long enough for us to
return