[SOLVED] Extend OUTPUT pins of a PIC microcontroller with the help of output shift register

Status
Not open for further replies.

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

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​

;;;;;;;;;;;;;;;;;1 sec delay;;;;;;;;;;;;;;;;;;;;;;;
DELAY1s
;999990 cycles
movlw 0x07
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3​
Delay_01
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​

MAIN
BSF STATUS,RP0
MOVLW B'00000'
MOVWF TRISA
BCF STATUS,RP0
CLRF PORTA​
LUPHR
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​
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;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
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​

The schematic is given below:-
 
Last edited:

If I understand correctly you have 8 leds connected at the outputs of 74HC595.

According to the datasheet the max current for each pin is 35mA so you have no problem with that but note that the total Vcc current max is 70mA so if all your leds turn on at the same time then you may have a problem.

Alex
 
Mr. Alex,
Thank you very much for your comment.
By chance I never have turned on all the LEDs at the same time. That’s how I managed to escape possible problem. Surely I will follow your suggestion.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…