Microcontroller chip - 74HC595

Publisher:Joyful444LifeLatest update time:2016-12-26 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The first part is for quick reference, see the second part of the article for detailed usage

Pin Diagram

 

 

Pin 14: DS (SER), serial data input pin

Pin 13: OE, output enable control pin, it enables output only when the power is low, so connect it to GND

Pin 12: RCK, storage register clock input pin. When the rising edge occurs, data is transferred from the shift register to the storage register.

Pin 11: SCK, shift register clock pin. When the pin rises, the bit data in the shift register shifts back as a whole and accepts the new bit (from SER input).

Pin 10: MR, when low level, clears the existing bit data in the shift register. Generally, it is not used and can be connected to a high level.

Pin 9: Serial data output pin. When the data in the shift register exceeds 8 bits, the existing bits will be "squeezed out" and output from here. Used for cascading 595.

Qx: Parallel output pin

 

Using Parameters

VCC: 2V~6V, 5V is best

I Qn: +- 35mA

 

Notice

The first bit sent from SER will go out from Q7.

 

 

 

74HC595 Introduction

Between a picture and a piece of text, which way of information delivery gives the greatest visual impact? I think everyone has the answer in their hearts.

This is also the reason for the title of my article. Enough of the nonsense, I will use pictures to analyze the 595 chip.

 

The most important function of 74HC595 is: serial input, parallel output. 3-state high-speed shift register (very awesome)

There are two 8-bit registers in 595: shift register and storage register

 

Shift Register

In my opinion, the shift register of 74HC595 works like a shou qiang magazine. But the firing of bullets (data in shift register is transferred to storage register) is like a scattershot (because it is parallel output).

 

 

Why do you say it is similar to a magazine?

1. Serial input, the bit data that has been entered is shifted down in sequence (so it is called a shift register) | The bullets are also put in one by one, the bullets that are put in first are slowly pushed down by the bullets that are put in later.

2. The first bit input is the last bit output in parallel | The first bullet to enter the magazine is the last to be fired.

 

 

Pin diagram of 74HC595

Pin 14: DS, also called SER. The full English name is: Serial data input. As the name suggests, it is the serial data input port.

The data source of 595 is only this one port, and only one bit can be input at a time. So if it is input 8 times in a row, it can be accumulated into a byte.

 

Suppose we want to input the binary data 0111 1111 into the 595 shift register. Here is a dynamic diagram that simulates the input of the first two bits.

This picture has 7 frames and took a long time to make. After all, I am not an artist. It can be said that everyone has their own expertise and there are different levels of knowledge. I still need to learn with an open mind :)

 

0111 1111 This is what the data looks like after it is fully entered.

We also need to pay attention to one pin: pin 11, (shift register clock input) shift register clock pin. The rising edge is valid.

First we need to introduce the function of this pin.

We know that the work of 51 single-chip microcomputer is inseparable from the crystal oscillator, which makes the working pace of CPU stable and orderly, just like the person shouting 1, 2, 1 while running.

The same principle applies to the shift register clock here. When a new bit of data is about to come in, the bit of data that has already entered will be moved back as a whole to make room under the control of the shift register clock pulse.

Rising edge: The process where the level changes from low to high. The shift register clock only works during the rising edge.


Storage Registers

So far we have roughly talked about how to load the bullets and have loaded them all. Now let's talk about how to fire the bullets, that is, how to transfer the data of the shift register to the storage register.

The storage register is directly connected to the 8 output pins. After the data of the shift register is transferred to the storage register, Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 can receive the data brought to our

The so-called storage register means that data can be stored in this register and will not disappear after one output. As long as the 595 is powered on and no new data is input,

When data comes from the shift register, the data remains unchanged and valid. When new data comes, the data in the storage register will be overwritten and updated.

 

Pin 12: (storage register clock input) Storage register clock

The data is transferred from the shift register to the storage register, which also needs to be driven by a clock pulse, which is the role of pin 12. It is also valid on the rising edge.

 

 

So far, we have explained the normal working process of 595. Now let's write a program to make the 8 LEDs keep the effect of bright and dark at intervals.

Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 are connected to the positive poles of 8 LEDs respectively

14-pin SER connects to MCU P3.4

Pin 11 SCK connects to MCU P3.6

12-pin RCK connects to MCU P3.5

Pin 13 OE connected to GND

Pin 10 MR connected to VCC

Pin 9 is not connected.

#include#includetypedef unsigned char uchar;
typedef unsigned int uint;/**********Function declaration********************/void SendTo595(uchar byteData);
/***********************************/sbit SER = P3^4; //p3.4 pin controls serial data input sbit SCK = P3^6; //serial input clock sbit RCK = P3^5; //storage register clock void main()
{

       SendTo595(85); //85 in binary: 0101 0101
       
       while(1);


}//Function: Send a byte of data to 595 and then output it in parallel void SendTo595(uchar byteData)
{ char i=0;
    for(;i<8;i++)
   {
           SER = byteData>>7; //Please consider these two sentences yourself
        byteData = byteData<<1;      

          SCK = 1; //Rising edge, let the serial input clock become high level and delay 2 clock cycles _nop_();
        _nop_();

        SCK = 0; //becomes low level, ready for next time }  
   
   /*Shift register data is ready, transfer to storage register*/
   RCK = 1; //Rising edge, make the storage register clock become high level and delay 2 clock cycles _nop_();
   _nop_();
   RCK = 0; 

}


 

Extension and promotion

Now you can see how powerful 595 is. 138 decoder controls 8 output ports through 3 input ports, and it can only have 8 specific output values.

The 595 uses only one input port to input any 8-bit data. It is compact and powerful.

What? You think 1-bit control 8-bit output is not enough? Connect your 595s in series and make them into a Gatling gun.

 

The 9th pin used in the above program is useless. If you want to connect two 595s in series, you need it.

Think about it, what happens if we fill the shift register with 8 bits and then put another bit in the shift register? Maybe you have thought of it.

Yes! The last bit of the shift register will be squeezed out. Where will it go out? It is output from pin 9.

Pin 9 is connected to the second serial data input pin SER, so a cascade of 595 is formed. In this way, if we use two 595s to form a new super 595,

The capacity of the shift register and storage register of this 595 has doubled, 1 port controls 16 ports, right? You can also continue to cascade!

 

Finally, there are 2 595 feet left unmentioned.

Pin 13 OE is the output enable control pin. If it does not work, the output of 595 will be in high impedance state, and 595 will not be controlled by our program, which is obviously against our wishes.

A line is drawn on OE, indicating that it is active at low level. So we connect it to GND.

 

Pin 10 MR, shift register clear pin, its function is to clear all the data in the shift register, this is rarely used, so we usually do not let it work, it

It is also valid at low level, so we connect it to VCC.

 

Finally finished, hope to help you. In the future, I will continue to explain other 74 series logic chips, so stay tuned!

Please point out any mistakes. :)


Reference address:Microcontroller chip - 74HC595

Previous article:MCU RS485 communication interface, control line, schematic diagram and program example
Next article:MCU independent buttons and matrix buttons

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号