list p=16f628A ; list directive to define processor
#include <p16F628A.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.
cblock 0x20 ;Ram address
TX ;the 4015
CountSPI
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
endc
#define Data PORTA,0 ;hardware
#define Clock PORTA,1
#define Clock0 PORTA,2
org 0x0000 ;reset
goto Main
org 0x04 ;interrupt vector
goto Main ;no interrupts
include "HC4015.inc"
Main ;main program
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
banksel TRISA
movlw b'00011000' ;initializing porta
movwf TRISA
banksel PORTA
clrf PORTA
Send
movlw b'00000001' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
call Delay
goto Send1
Send1
movlw b'00000010' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
call Delay
goto Send2
Send2
movlw b'00000100' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
call Delay
goto Send3
Send3
movlw b'00001000' ;fill tx buffer
movwf TX
call Delay
HC4015 TX,CountSPI
goto Send4
Send4
movlw b'00010000' ;fill tx buffer
movwf TX
call Delay
HC4015 TX,CountSPI
goto Send5
Send5
movlw b'00010000' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
call Delay
goto Send6
Send6
movlw b'00100000' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
call Delay
goto Send7
Send7
movlw b'01000000' ;fill tx buffer
movwf TX
call Delay
HC4015 TX,CountSPI
goto Send8
Send8
movlw b'10000000' ;fill tx buffer
movwf TX
call Delay
HC4015 TX,CountSPI
goto Send
Loop
goto Loop ;hang out here
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 ; directive 'end of program'