;Tutorial 1.5 - Nigel Goodwin 2002
LIST p=16F648A ;tell assembler what chip we are using
include "P16F648A.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings (oscillator type etc.)
cblock 0x20 ;start of general purpose registers
count ;used in table read routine
count1 ;used in delay routine
count2
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)
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
Start clrf count ;put counter value in W
Read movf count, w ;put counter value in W
call Table
movwf LEDPORT
call Delay
incf count, w
xorlw d'18' ;check for last (18th) entry
btfsc Status, Z
goto Read2 ;if start from beginning
incf count, f ;else do next
goto Read
Table ADDWF PCL, f ;data table for bit pattern
retlw b'10000000'
retlw b'11000000'
retlw b'11100000'
retlw b'01110000'
retlw b'00111000'
retlw b'00011100'
retlw b'00001110'
retlw b'00000111'
retlw b'00000011'
retlw b'00000001'
retlw b'00000011'
retlw b'00001110'
retlw b'00011100'
retlw b'00111000'
retlw b'01110000'
retlw b'11100000'
retlw b'11000000'
retlw b'10000000'
Read2 clrf count2
movf count2, w ;put counter value in W
call Table2
movwf LEDPORT
call Delay
incf count2, w
xorlw d'13' ;check for last (13th) entry
btfsc Status, Z
goto Start ;if start from beginning
incf count2, f ;else do next
goto Read2
Table2 ADDWF PCL, f ;data table for bit pattern
retlw b'10000001'
retlw b'11000011'
retlw b'11100111'
retlw b'01111110'
retlw b'00111100'
retlw b'00011000'
retlw b'00000000'
retlw b'00011000'
retlw b'00111100'
retlw b'01111110'
retlw b'11100111'
retlw b'11000011'
retlw b'10000001'
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