;Tutorial 1.5 - Nigel Goodwin 2002
LIST p=16F88 ;tell assembler what chip we are using
include "P16F88.inc" ;include the defaults for the chip
; __config 0x3F38 ;sets the configuration settings (oscillator type etc.)
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
cblock 0x20 ;start of general purpose registers
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
endc
LEDPORT Equ PORTB ;set constant LEDPORT = 'PORTB'
LEDTRIS Equ TRISB ;set constant for TRIS register
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)
movlw b'01100000' ;Set int osc to 4mhz
movwf OSCCON & 0x7F
bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB all outputs
movwf LEDTRIS
bcf STATUS, RP0 ;select bank 0
clrf LEDPORT ;set all outputs low
Loop
; movlw b'10000000'
movlw b'11111111'
movwf LEDPORT
call Delay ;this waits for a while!
movlw b'01000000'
movwf LEDPORT
call Delay ;this waits for a while!
movlw b'00100000'
movwf LEDPORT
call Delay ;this waits for a while!
movlw b'00010000'
movwf LEDPORT
call Delay ;this waits for a while!
movlw b'00001000'
movwf LEDPORT
call Delay ;this waits for a while!
movlw b'00000100'
movwf LEDPORT
call Delay ;this waits for a while!
movlw b'00000010'
movwf LEDPORT
call Delay ;this waits for a while!
movlw b'00000001'
movwf LEDPORT
call Delay ;this waits for a while!
goto Loop ;go back and do it again
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