LIST p=16F628a ;tell assembler what chip we are using
include "P16F628a.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings
;(oscillator type etc.)
cblock 0x20 ;start of general purpose registers
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
endc
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
movwf TRISA ;set PortA all outputs
bcf STATUS, RP0 ;select bank 0
main:
banksel PORTA
bsf PORTA,5 ;change this for each roll 6 and then 7
goto blinkleds
blinkleds:
banksel PORTB
bsf PORTB,0
call delay
bcf PORTB,0
call delay
bsf PORTB,1
call delay
bcf PORTB,1
call delay
bsf PORTB,2
call delay
bcf PORTB,2
call delay
bsf PORTB,3
call delay
bcf PORTB,3
call delay
bsf PORTB,4
call delay
bcf PORTB,4
call delay
bsf PORTB,5
call delay
bcf PORTB,5
call delay
bsf PORTB,6
call delay
bcf PORTB,6
call delay
bsf PORTB,7
call delay
bcf PORTB,7
call delay
banksel PORTA
bsf PORTA,4
call delay
bcf PORTA,4
call delay
goto blinkleds
delay
movlw d'250' ;delay 250 ms (4 MHz clock)
movwf count1
d1 movlw 0xC7
movwf counta
movlw 0x01
movwf countb
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0
decfsz count1 ,f
goto d1
retlw 0x00
end