; progam to flash all of PortB pins on and off every 4 seconds
; based on a 4 mhz crystal
list p=16f877
include p16f877.inc
__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON & _LVP_OFF
cblock 0X20 ; specify user regiaters ( easier than EQU)
d1
d2
d3
COUNT
endc
org 0x000
GOTO Main
Main CLRF PORTB ; Set portb,c,d to digital outputs
CLRF PORTC
CLRF PORTD
BANKSEL TRISA
CLRF TRISB
CLRF TRISC
CLRF TRISD
BANKSEL 0
LOOP ; main program looP
CALL DELAY4s ; call this subrutine
MOVLW 0xFF
MOVWF PORTB ; Set port HIGH
CALL DELAY4s
MOVLW 0x00
MOVWF PORTB ; Set port LOW
GOTO LOOP
; SUBROUTINES
DELAY4s ; 4 SECOND DELAY
movlw 0x23
movwf d1
movlw 0xB9
movwf d2
movlw 0x09
movwf d3
Delay_0
decfsz d1, f
goto dly1
decfsz d2, f
dly1 goto dly2
decfsz d3, f
dly2 goto Delay_0
return
END ; END OF PROGRAM CODE