Do_Show call Reset ;reset 74HC
bsf Data ;make 74HC data pin high for the first time
movf Col1,W
call Clock_Pulse
bcf Data ;make 74HC data pin low
movf Col2,W
call Clock_Pulse
movf Col3,W
call Clock_Pulse
movf Col4,W
call Clock_Pulse
movf Col5,W
call Clock_Pulse
goto Do_Show
Clock_Pulse movwf Col_Data ;get the column data
clrf PORTB
bsf Clock ;low to high transition
bcf Clock ;make low for next transition
movf Col_Data,W
movwf PORTB
return
..
bsf Clock ;low to high transition
nop ;give shift register time to act
bcf Clock ;make low for next transition
...
Reset bsf STATUS,RP0
bcf TRISA,2 ;make RA2 output
bcf STATUS,RP0
;
bcf PORTA,2 ;reset pulse
nop ;//
nop ;//
bsf STATUS,RP0
bsf TRISA,2 ;;make RA2 input
bcf STATUS,RP0
return
Dataout macro Var,Var1
Local Loop
movlw .8
movwf Var1
Loop rlf Var,f
btfss STATUS,C
bcf Data
btfsc STATUS,C
bsf Data
bsf Clock
nop
nop
nop
nop
bcf Clock
decfsz Var1,f
goto Loop
endm
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
goto Send1
Send1
movlw b'00000010' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
goto Send2
Send2
movlw b'00000100' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
goto Send3
Send3
movlw b'00001000' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
goto Send4
Send4
movlw b'00010000' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
goto Send5
Send5
movlw b'00010000' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
goto Send6
Send6
movlw b'00100000' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
goto Send7
Send7
movlw b'01000000' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
goto Send8
Send8
movlw b'10000000' ;fill tx buffer
movwf TX
HC4015 TX,CountSPI
goto Send
Loop
;**********************************
;Clock pulse routine to SR-74HC164
;**********************************
Clock_Pulse movwf Col_Data ;save column data
clrf PORTB
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
bsf PORTA,0 ;low to high transition
nop
bcf PORTA,0 ;make low for next transition
nop
movf Col_Data,W
movwf PORTB
goto $+1
goto $+1
return
#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
HC595 macro Var,Var1
Local Loop ;label
movlw .8 ;eight bits to send
movwf Var1
Loop
rlf Var,f ;rotate Var to the left
btfss STATUS,C ;carry = 1 ?
bcf Data ;if not set line to 0
btfsc STATUS,C ;is carry = 0 ?
bsf Data ;if not set, set data line to 1
bsf Clock ; generate 1 clock
nop
bcf Clock
decfsz Var1,f ;bits been sent ?
goto Loop ;if not repeat
bsf Latch
nop
bcf Latch
endm
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?