Log In: Using 74HC595 To Expand Output Pins of A PIC Microcontroller: Assembly Code

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

LOG IN  

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics


Discussion Forum focused on EDA software, circuits, schematics, books,
theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB,
Service Manuals... and a whole lot more! To participate you need to
register. Registration is free. Click here to register now.

Register Log in

 papunblg' s Blo g

Using 74HC595 to expand output pins of a PIC microcontroller: Assembly code


 papunblg ·  Apr 14, 2012

Blog ent ry Gallery (1)

This is act ually a cont inuat ion of my blog ent ry ht t ps://www.edaboard.com/blog/1628/ where I have used C
language rout ine. Now it s t he t ime t o use Assembly Language for PIC. The Code is t est ed on PIC16F84A wit h 4MHz
cryst al. Compiler used MCS-51 under M-IDE St udio.

The associat ed program shows how t o t ransfer a byt e dat a serially t o t he 74HC595 and t hen set s t he out put
accordingly.

According t o page 5 of Dat asheet , t he out put s of 74HC595 provide 8 mA. Though I have used 330E resist ors t o
drive LEDs , t his should not be done! It is t herefore recommended t o connect a higher resist ance (620E). LEDs light
up very, very lit t le, but enough t o t est t he circuit .

I will mainly cover t he t echnical det ails t o connect a 74HC595 wit h a microcont roller. I will avoid t he t heory of a
shift regist er and all t hose t heoret ical det ails.

The dat a are t ransferred int o t he shift regist er 74HC595 pin t hrough t he PIN 14 (Serial dat e).
PIN 11 (Shift regist er clock). Once finished sending dat a, just bring a high level on t he pin 12 (St orage Clock or Lat ch)
t o t ransfer dat a from t he shift regist er t o t he lat ch. The pin 13 (Out put Enable - act ive low) enables t he t ransfer of
dat a from t he lat ch t o t he out put port s when it is brought low: since we connect ed t he drive pin t o ground, t hey
meet again on t he dat a out put s as soon as we give t he shot clock on t he lat ch. The pin 10 is t he mast er reset :
placing it at a low level reset s t he cont ent s of t he shift regist er, for which we keep it up for safet y. The pin 9 we
keep it disconnect ed because it is not used in t his applicat ion.

You can use any microcont roller but be careful, in case of open collect or pins, add pull up resist ors.
Code - [expand]
Code - [expand]

1 ;Following is the code to switch on alternate LEDs for 1 seconds


2
3
4 list p=16F84A
5 #include <p16F84A.inc>
6 __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
7 ERRORLEVEL -302
8
9
10 CBLOCK 0X0C
11 TX ;
12 COUNTSPI
13 d1
14 d2
15 d3
16 ENDC
17
18 #define DATA1 PORTA,0
19 #define CLOCK PORTA,1
20 #define LATCH PORTA,2
21
22 ORG 0X00
23 GOTO MAIN
24
25 #include "HC595.INC" ;;Thanks to Nebojsa Matic of mikroElektronika for idea
26
27 ;;;;;;;;;;;;;;;;;1 sec delay;;;;;;;;;;;;;;;;;;;;;;;
28 DELAY1s
29
30
31 ;999990 cycles
32 movlw 0x07
33 movwf d1
34 movlw 0x2F
35 movwf d2
36 movlw 0x03
37 movwf d3
38 Delay_01
39
40 decfsz d1, f
41 goto $+2
42 decfsz d2, f
43 goto $+2
44 decfsz d3, f
45 goto Delay_01
46
47 ;6 cycles
48 goto $+1
49 goto $+1
50 goto $+1
51
52 ;4 cycles (including call)
53 return
54
55 MAIN
56
57 BSF STATUS,RP0
58 MOVLW B'00000'
59 MOVWF TRISA
60 BCF STATUS,RP0
61 CLRF PORTA
62 LUPHR
63
64 CLRF PORTA
65 MOVLW B'10101010'
66 MOVWF TX
67 HC595 TX,COUNTSPI
68 CALL DELAY1s
69 CLRF PORTA
70 MOVLW B'01010101'
71 MOVWF TX
72 HC595 TX,COUNTSPI
73 CALL DELAY1s
74 GOTO LUPHR
75 END

And t he HC595.inc library


Code - [expand]

1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;HC595.inc;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;
3 ;Thanks to Nebojsa Matic of mikroElektronika for idea
4 ;Var variable whose contents is transferred to outputs of shift register.
5 ;Var1 loop counter
6 ;Here 8bit data is used, so VAR1 gets decimal 8 to continue the loop for 8 times
7
8 HC595 MACRO VAR,VAR1
9
10 LOCAL LOOP
11 MOVLW .8
12 MOVWF VAR1
13 LOOP
14
15 RLF VAR,F
16 BTFSS STATUS,C
17 BCF DATA1
18 BTFSC STATUS,C
19 BSF DATA1
20
21 BSF CLOCK
22 NOP
23 BCF CLOCK
24
25 DECFSZ VAR1,F
26 GOTO LOOP
27
28 BSF LATCH
29 NOP
30 BCF LATCH
31
32 ENDM

Share:       

Comments

There are no comment s t o display.

 PART AND INVENT ORY SEARCH

Part Search

 BLOG ENT RY INFORMAT ION

Author: papunblg
Views: 383
Last update: Apr 14, 2012

 MORE ENT RIES IN UNCAT EGORIZED

Micromachined Spring Probe Component s


Small is a relative term. In the 1990's a small PC socket was a leaded...

N
[Debug][Keil][STM32CubeIDE] How t o debug Keil's STM32 project in STM32CubeIDE?
The background: I have found a way to debug a Keil's project using...
N
[Debug][Keil][VSCode] How t o debug Keil's STM32 project in VSCode?
Assumptions: STM32CubeIDE needs to be installed. At the time of...

PCB pad design for machined int erconnect s


Introduction: Specifying the correct printed circuit board pad, land...

N
[Keil][STM32CubeIDE] Keil int egrat ion int o STM32CubeIDE
The background: I have to use Keil in my job and honestly - I don't...

 MORE ENT RIES FROM PAPUNBLG

How t o int erface PIR modules wit h PIC microcont rollers


In this project a Passive Infrared (PIR) sensor is used to detect human...

How t o expand I/O pins of a microcont roller using 74HC595 C Code


In this blog entry I will show you how to use a 74HC595 to expand I/O...

Use of Vref+ pin of PIC16F87xA ADC [applicable t o all micro]


The maximum analog voltage you can give to your PIC (directly, without...

ADC Conversion Clock Select bit set t ing for PIC16F87XA, 18F2x2, 18F4x microcont roller
There is a fact to mention about the resolution of the A/D converter...

Display t emperat ure on LCD 16x2 display using LM35 and Pic16F876A
Code to display temperature on LCD 16x2 display using LM35 and...

 SHARE T HIS ENT RY

      

Copy URL BB code:

[URL="https://www.edaboard.com/blog/using-74hc595-to-expand-output-pins-of-a-pic-microcontroller-assembly-code.1629/"]Using

Copy UBS BB code:

[UBS=entry, 1629][/UBS]

 papunblg' s Blo g

Co nne ct with us

  
Online statistics

Members o nline: 9

Guests o nline: 839

To tal visito rs: 848

To tals may include hidden visito rs.

Fo rum statistics
Threads: 376,232

Messages: 1,649,681

Members: 593,226

Latest member: ylpylg

What's ne w

 New po sts

 New pro file po sts

 Latest activity

Co pyright © 2021 WTWH Media, LLC. All Rights Reserved.

Style cho o ser

Co ntact us Terms and rules Privacy po licy Help Ho me 


This site uses co o kies to help perso nalise co ntent, tailo r yo ur experience and to keep yo u lo gged in if yo u register.
By co ntinuing to use this site, yo u are co nsenting to o ur use o f co o kies.

 Accept Learn mo re…

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy