Hi, i have been playing around with a 16F628A and a 595 chip but i have som problems and i wonder if the problem is hardware or software related
Code:
;*******************************************************
; 74HC595 parallel to serial routine .
;
; Author Stig Larsen
;
; Pic16F628A
;
; januar 2015
;
;*********************************************************
list p=16f628A ; list directive to define processor
#include <p16f628a.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _FOSC_INTOSCCLK & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _BOREN_ON & _LVP_ON & _CPD_OFF & _CP_OFF
cblock 0x20
data1
test
RXT
d1
d2
d3 ;
;VARF
endc
;***** VARIABLE DEFINITIONS
;data1 EQU 0x70 ;
data2 EQU 0x71 ;
;RXT EQU 0x72
VARF EQU 0X73
;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
;
; defines
;
;*******************HC595 pins****************************************
; Pic pin 17 (DS)to pin 14
; Pic pin 18 (SH)to pin 11
; Pic pin 1 (ST)to pin 12
; 595 Pin 10 16 to +
; 595 Pin 8 13 to Gnd
;********************************************************************
#define PIN_DS PORTA,0 ; DS (serial data in)
#define PIN_SH PORTA,1 ; SH_CP(shift)
#define PIN_ST PORTA,2 ; ST_CP (latch)
;****************************************************************
; Port init
;
;****************************************************************
main
CLRF PORTA
MOVLW 0x07
MOVWF CMCON
BCF STATUS, RP1
BSF STATUS, RP0 ;Select Bank1
MOVLW b'00001000'
MOVWF TRISA
MOVLW 0xf0
MOVWF TRISB
BANKSEL PORTA
;************hc595 routine test **************
_595
movlW .8
movwf RXT
;clrf data1
movlw b'11110000'
movwf data1
bcf PIN_ST
d0
btfsc data1,7
bsf PIN_DS
btfss data1,7
bcf PIN_DS
bsf PIN_SH
nop
bcf PIN_SH
rlf data1
DECFSZ RXT,F
goto d0
bsf PIN_ST
nop
bcf PIN_ST
call Delay
goto _595
Delay
;3999994 cycles
movlw 0x23
movwf d1
movlw 0xB9
movwf d2
movlw 0x09
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;2 cycles
goto $+1
;4 cycles (including call)
return
end