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#include typedef 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. :)
Previous article:MCU RS485 communication interface, control line, schematic diagram and program example
Next article:MCU independent buttons and matrix buttons
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
- STC MCU Principles and Applications: Analysis and Design from Devices, Assembly, C to Operating Systems: A Three-Dimensional Tutorial (He Bin)
- Arduino Development Guide: STM32
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to replace STM32 with GD32?
- [Homemade] DS-T10 Portable Smart Soldering Iron
- Award-winning live broadcast: Unlocking the black technology of automotive electronics and creating a new realm of future driving
- Frequently Asked Questions about Lingdongwei MM32F103 MCU
- The problem of increasing the driving capability of the oscillation circuit
- Antenna Design Solutions for Next Generation Mobile Devices
- Chapter 3 Using external interrupt EXTI to read keystrokes
- What are the effects of placing TVS tubes in front and behind? Which one is correct? Why?
- MAGTROL HD-106-8NA-0100 Dynamometer Failure
- Which big shot can surpass the design in the picture and realize fingerless touch screen?