papunblg
Advanced Member level 3
- Joined
- Oct 22, 2010
- Messages
- 716
- Helped
- 172
- Reputation
- 344
- Reaction score
- 165
- Trophy points
- 1,343
- Location
- Kolkata India
- Activity points
- 6,421
Extend OUTPUT pins of a PIC micror with the help of output shift register 74HC595
Expert opinions will be very much appreciated with due respect to update this project.
This is how I have extended the pins of a PIC16F84A microcontroller with the help of an output shift register (IC 74HC595) which I have used in another project to display ASCII characters using 8x8 (or 5x7) MATRIX. Project is working fine. Do I need any modification?
;Following is the code to switch on alternate LEDs for 1 seconds
;;;;;;;;;;;;;;;;;1 sec delay;;;;;;;;;;;;;;;;;;;;;;;
DELAY1s
MAIN
;;;;;;;;;;;;;;;;;;;;;;;;;;;HC595.inc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Thanks to Nebojsa Matic of mikroElektronika for idea
;Var variable whose contents is transferred to outputs of shift register.
;Var1 loop counter
;Here 8bit data is used, so VAR1 gets decimal 8 to continue the loop for 8 times
HC595 MACRO VAR,VAR1
The schematic is given below:-
Expert opinions will be very much appreciated with due respect to update this project.
This is how I have extended the pins of a PIC16F84A microcontroller with the help of an output shift register (IC 74HC595) which I have used in another project to display ASCII characters using 8x8 (or 5x7) MATRIX. Project is working fine. Do I need any modification?
;Following is the code to switch on alternate LEDs for 1 seconds
list p=16F84A
#include <p16F84A.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ERRORLEVEL -302
CBLOCK 0X0C
TX ;
COUNTSPI
d1
d2
d3
ENDC
#define DATA1 PORTA,0
#define CLOCK PORTA,1
#define LATCH PORTA,2
ORG 0X00
GOTO MAIN
#include "HC595.INC" ;;Thanks to Nebojsa Matic of mikroElektronika for idea
#include <p16F84A.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ERRORLEVEL -302
CBLOCK 0X0C
TX ;
COUNTSPI
d1
d2
d3
ENDC
#define DATA1 PORTA,0
#define CLOCK PORTA,1
#define LATCH PORTA,2
ORG 0X00
GOTO MAIN
#include "HC595.INC" ;;Thanks to Nebojsa Matic of mikroElektronika for idea
;;;;;;;;;;;;;;;;;1 sec delay;;;;;;;;;;;;;;;;;;;;;;;
DELAY1s
;999990 cycles
movlw 0x07
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_01movlw 0x07
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_01
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_01
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
MAIN
BSF STATUS,RP0
MOVLW B'00000'
MOVWF TRISA
BCF STATUS,RP0
CLRF PORTA
LUPHRMOVLW B'00000'
MOVWF TRISA
BCF STATUS,RP0
CLRF PORTA
CLRF PORTA
MOVLW B'10101010'
MOVWF TX
HC595 TX,COUNTSPI
CALL DELAY1s
CLRF PORTA
MOVLW B'01010101'
MOVWF TX
HC595 TX,COUNTSPI
CALL DELAY1s
GOTO LUPHR
END
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MOVLW B'10101010'
MOVWF TX
HC595 TX,COUNTSPI
CALL DELAY1s
CLRF PORTA
MOVLW B'01010101'
MOVWF TX
HC595 TX,COUNTSPI
CALL DELAY1s
GOTO LUPHR
END
;;;;;;;;;;;;;;;;;;;;;;;;;;;HC595.inc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Thanks to Nebojsa Matic of mikroElektronika for idea
;Var variable whose contents is transferred to outputs of shift register.
;Var1 loop counter
;Here 8bit data is used, so VAR1 gets decimal 8 to continue the loop for 8 times
HC595 MACRO VAR,VAR1
LOCAL LOOP
MOVLW .8
MOVWF VAR1
LOOP MOVLW .8
MOVWF VAR1
RLF VAR,F
BTFSS STATUS,C
BCF DATA1
BTFSC STATUS,C
BSF DATA1
BSF CLOCK
NOP
BCF CLOCK
DECFSZ VAR1,F
GOTO LOOP
BSF LATCH
NOP
BCF LATCH
ENDM
BTFSS STATUS,C
BCF DATA1
BTFSC STATUS,C
BSF DATA1
BSF CLOCK
NOP
BCF CLOCK
DECFSZ VAR1,F
GOTO LOOP
BSF LATCH
NOP
BCF LATCH
ENDM
The schematic is given below:-
Last edited: