#include <p12f683.inc> ; Include pre-defined port/reg labels
errorlevel -302 ; suppress message 302 from list file
__CONFIG _FCMEN_ON & _IESO_OFF & _CP_OFF & _CPD_OFF & _BOD_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
cblock 0x20
TX ; Define variable at address 0x20 of
CountSPI
d1
d2
endc ; General Purpose Register (GPR) memory.
#define Data GPIO,0
#define Clock GPIO,1
#define Latch GPIO,2
org 0x0000 ; Processor Reset Vector (code starts here on reset)
goto Main ; On power-up, begin at label "Main:"
org 0x0004 ; Interrupt Vector (code jumps here on interrupt)
goto Main ; Applies to midrange parts!
include "hc595."
Main:
movlw 07h ;set GP<2:0> to
movfw CMCON0 ;digital I/O
banksel ANSEL;
clrf ANSEL;digtal I/O
banksel TRISIO
movlw b'011000' ;set inputs and outputs
movwf TRISIO ;moves it to TRIS ; Initialize any ports as inputs/outputs, etc. here
banksel GPIO
clrf GPIO
Loop:
Send
movlw b'00000001' ;fill tx buffer
movwf TX
HC595 TX,CountSPI
call delay
goto Send1
Send1
movlw b'00000010' ;fill tx buffer
movwf TX
HC595 TX,CountSPI
call delay
goto Send2
Send2
movlw b'00000100' ;fill tx buffer
movwf TX
HC595 TX,CountSPI
call delay
goto Send3
Send3
movlw b'00001000' ;fill tx buffer
movwf TX
HC595 TX,CountSPI
call delay
goto Send4
Send4
movlw b'00010000' ;fill tx buffer
movwf TX
HC595 TX,CountSPI
call delay
goto Send5
Send5
movlw b'00100000' ;fill tx buffer
movwf TX
HC595 TX,CountSPI
call delay
goto Send6
Send6
movlw b'01000000' ;fill tx buffer
movwf TX
HC595 TX,CountSPI
call delay
goto Send7
Send7
movlw b'10000000' ;fill tx buffer
movwf TX
HC595 TX,CountSPI
call delay
goto Send ; Place Application Code Here.
goto Loop
delay:
;149998 cycles
movlw 0x2F
movwf d1
movlw 0x76
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0
;2 cycles
goto $+1
return
end ; Program code stops here